git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277661 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -98,7 +98,7 @@ class SvnChangeLogParser extends LineOrientedOutputStream { | |||||
| //We have ended changelog for that particular revision | //We have ended changelog for that particular revision | ||||
| //so we can save it | //so we can save it | ||||
| final int end | final int end | ||||
| = message.length() - lineSeparator.length(); //was -1 | |||||
| = message.length() - lineSeparator.length(); | |||||
| message = message.substring(0, end); | message = message.substring(0, end); | ||||
| saveEntry(); | saveEntry(); | ||||
| status = GET_REVISION_LINE; | status = GET_REVISION_LINE; | ||||
| @@ -147,8 +147,8 @@ class SvnChangeLogParser extends LineOrientedOutputStream { | |||||
| // ignore | // ignore | ||||
| } else if (line.equals("")) { | } else if (line.equals("")) { | ||||
| status = GET_MESSAGE; | status = GET_MESSAGE; | ||||
| } else { | |||||
| paths.add(line.substring(5)); | |||||
| } else if (line.length() > 5) { | |||||
| paths.add(new SvnEntry.Path(line.substring(5), line.charAt(3))); | |||||
| } | } | ||||
| } | } | ||||
| @@ -159,6 +159,7 @@ class SvnChangeLogParser extends LineOrientedOutputStream { | |||||
| SvnEntry entry = new SvnEntry(date, revision, author, message, | SvnEntry entry = new SvnEntry(date, revision, author, message, | ||||
| paths); | paths); | ||||
| entries.add(entry); | entries.add(entry); | ||||
| reset(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -46,7 +46,7 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| * <font color=#0000ff><!-- Root element --></font> | * <font color=#0000ff><!-- Root element --></font> | ||||
| * <font color=#6a5acd><!ELEMENT</font> changelog <font color=#ff00ff>(entry</font><font color=#ff00ff>+</font><font color=#ff00ff>)</font><font color=#6a5acd>></font> | * <font color=#6a5acd><!ELEMENT</font> changelog <font color=#ff00ff>(entry</font><font color=#ff00ff>+</font><font color=#ff00ff>)</font><font color=#6a5acd>></font> | ||||
| * <font color=#0000ff><!-- SVN Entry --></font> | * <font color=#0000ff><!-- SVN Entry --></font> | ||||
| * <font color=#6a5acd><!ELEMENT</font> entry <font color=#ff00ff>(date,time,revision,author,file</font><font color=#ff00ff>+,msg</font><font color=#ff00ff>,msg)</font><font color=#6a5acd>></font> | |||||
| * <font color=#6a5acd><!ELEMENT</font> entry <font color=#ff00ff>(date,time,revision,author,path</font><font color=#ff00ff>+,msg</font><font color=#ff00ff>,msg)</font><font color=#6a5acd>></font> | |||||
| * <font color=#0000ff><!-- Date of svn entry --></font> | * <font color=#0000ff><!-- Date of svn entry --></font> | ||||
| * <font color=#6a5acd><!ELEMENT</font> date <font color=#ff00ff>(#PCDATA)</font><font color=#6a5acd>></font> | * <font color=#6a5acd><!ELEMENT</font> date <font color=#ff00ff>(#PCDATA)</font><font color=#6a5acd>></font> | ||||
| * <font color=#0000ff><!-- Time of svn entry --></font> | * <font color=#0000ff><!-- Time of svn entry --></font> | ||||
| @@ -55,10 +55,11 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| * <font color=#6a5acd><!ELEMENT</font> author <font color=#ff00ff>(#PCDATA)</font><font color=#6a5acd>></font> | * <font color=#6a5acd><!ELEMENT</font> author <font color=#ff00ff>(#PCDATA)</font><font color=#6a5acd>></font> | ||||
| * <font color=#0000ff><!-- commit message --></font> | * <font color=#0000ff><!-- commit message --></font> | ||||
| * <font color=#6a5acd><!ELEMENT</font> msg <font color=#ff00ff>(#PCDATA)</font><font color=#6a5acd>></font> | * <font color=#6a5acd><!ELEMENT</font> msg <font color=#ff00ff>(#PCDATA)</font><font color=#6a5acd>></font> | ||||
| * <font color=#0000ff><!-- List of files affected --></font> | |||||
| * <font color=#6a5acd><!ELEMENT</font> file <font color=#ff00ff>(name</font><font color=#ff00ff>?</font><font color=#ff00ff>)</font><font color=#6a5acd>></font> | |||||
| * <font color=#0000ff><!-- Name of the file --></font> | |||||
| * <font color=#0000ff><!-- List of paths affected --></font> | |||||
| * <font color=#6a5acd><!ELEMENT</font> path <font color=#ff00ff>(name,action)</font><font color=#ff00ff></font><font color=#ff00ff>)</font><font color=#6a5acd>></font> | |||||
| * <font color=#0000ff><!-- Name of the path --></font> | |||||
| * <font color=#6a5acd><!ELEMENT</font> name <font color=#ff00ff>(#PCDATA)</font><font color=#6a5acd>></font> | * <font color=#6a5acd><!ELEMENT</font> name <font color=#ff00ff>(#PCDATA)</font><font color=#6a5acd>></font> | ||||
| * <font color=#6a5acd><!ELEMENT</font> action <font color=#ff00ff>(added|modified|deleted)</font><font color=#6a5acd>></font> | |||||
| * <font color=#0000ff><!-- Revision number --></font> | * <font color=#0000ff><!-- Revision number --></font> | ||||
| * <font color=#6a5acd><!ELEMENT</font> revision <font color=#ff00ff>(#PCDATA)</font><font color=#6a5acd>></font> | * <font color=#6a5acd><!ELEMENT</font> revision <font color=#ff00ff>(#PCDATA)</font><font color=#6a5acd>></font> | ||||
| * </pre> | * </pre> | ||||
| @@ -65,16 +65,19 @@ public class SvnChangeLogWriter { | |||||
| + "</time>"); | + "</time>"); | ||||
| output.println("\t\t<author><![CDATA[" + entry.getAuthor() | output.println("\t\t<author><![CDATA[" + entry.getAuthor() | ||||
| + "]]></author>"); | + "]]></author>"); | ||||
| output.println("\t\t<revision><![CDATA[" + entry.getRevision() | |||||
| + "]]></revision>"); | |||||
| output.println("\t\t<revision>" + entry.getRevision() | |||||
| + "</revision>"); | |||||
| String[] paths = entry.getPaths(); | |||||
| SvnEntry.Path[] paths = entry.getPaths(); | |||||
| for (int i = 0; i < paths.length; i++) { | for (int i = 0; i < paths.length; i++) { | ||||
| output.println("\t\t<file>"); | |||||
| output.println("\t\t\t<name><![CDATA[" + paths[i] + "]]></name>"); | |||||
| output.println("\t\t</file>"); | |||||
| output.println("\t\t<path>"); | |||||
| output.println("\t\t\t<name><![CDATA[" + paths[i].getName() | |||||
| + "]]></name>"); | |||||
| output.println("\t\t\t<action>" + paths[i].getActionDescription() | |||||
| + "</action>"); | |||||
| output.println("\t\t</path>"); | |||||
| } | } | ||||
| output.println("\t\t<msg><![CDATA[" + entry.getMessage() + "]]></msg>"); | |||||
| output.println("\t\t<message><![CDATA[" + entry.getMessage() + "]]></message>"); | |||||
| output.println("\t</entry>"); | output.println("\t</entry>"); | ||||
| } | } | ||||
| } | } | ||||
| @@ -60,8 +60,8 @@ public class SvnEntry { | |||||
| * @param path the path to add | * @param path the path to add | ||||
| * @param revision the revision | * @param revision the revision | ||||
| */ | */ | ||||
| public void addPath(final String name) { | |||||
| paths.add(name); | |||||
| public void addPath(final String name, final char action) { | |||||
| paths.add(new Path(name, action)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -108,8 +108,56 @@ public class SvnEntry { | |||||
| * Gets the paths in this SvnEntry | * Gets the paths in this SvnEntry | ||||
| * @return the files | * @return the files | ||||
| */ | */ | ||||
| public String[] getPaths() { | |||||
| return (String[]) paths.toArray(new String[paths.size()]); | |||||
| public Path[] getPaths() { | |||||
| return (Path[]) paths.toArray(new Path[paths.size()]); | |||||
| } | |||||
| public static class Path { | |||||
| private static final char ADDED_MARKER = 'A'; | |||||
| private static final char MODIFIED_MARKER = 'M'; | |||||
| private static final char DELETED_MARKER = 'D'; | |||||
| public static final int ADDED = 0; | |||||
| public static final int MODIFIED = 1; | |||||
| public static final int DELETED = 2; | |||||
| private static final String[] ACTIONS = { | |||||
| "added", "modified", "deleted", | |||||
| }; | |||||
| private final String name; | |||||
| private final int action; | |||||
| public Path(final String name, final char actionChar) { | |||||
| this.name = name; | |||||
| switch (actionChar) { | |||||
| case ADDED_MARKER: | |||||
| action = ADDED; | |||||
| break; | |||||
| case MODIFIED_MARKER: | |||||
| action = MODIFIED; | |||||
| break; | |||||
| case DELETED_MARKER: | |||||
| action = DELETED; | |||||
| break; | |||||
| default: | |||||
| throw new IllegalArgumentException("Unkown action; " | |||||
| + actionChar); | |||||
| } | |||||
| } | |||||
| public String getName() { | |||||
| return name; | |||||
| } | |||||
| public int getAction() { | |||||
| return action; | |||||
| } | |||||
| public String getActionDescription() { | |||||
| return ACTIONS[action]; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||