Author: bodewig
Date: Tue May 5 13:11:49 2009
New Revision: 771707
URL: http://svn.apache.org/viewvc?rev=771707&view=rev
Log:
expand tagdiff to support branches as well. Submitted by Danny Angus. PR
47105.
Modified:
ant/antlibs/svn/trunk/contributors.xml
ant/antlibs/svn/trunk/docs/tagdiff.html
ant/antlibs/svn/trunk/src/etc/diff.xsl
ant/antlibs/svn/trunk/src/main/org/apache/ant/svn/SvnTagDiff.java
Modified: ant/antlibs/svn/trunk/contributors.xml
URL:
http://svn.apache.org/viewvc/ant/antlibs/svn/trunk/contributors.xml?rev=771707&r1=771706&r2=771707&view=diff
==============================================================================
--- ant/antlibs/svn/trunk/contributors.xml (original)
+++ ant/antlibs/svn/trunk/contributors.xml Tue May 5 13:11:49 2009
@@ -31,6 +31,10 @@
These are some of the many people who have helped with this Ant Library.
</introduction>
<name>
+ <first>Danny</first>
+ <last>Angus</last>
+ </name>
+ <name>
<first>Kevin</first>
<last>Jackson</last>
</name>
Modified: ant/antlibs/svn/trunk/docs/tagdiff.html
URL:
http://svn.apache.org/viewvc/ant/antlibs/svn/trunk/docs/tagdiff.html?rev=771707&r1=771706&r2=771707&view=diff
==============================================================================
--- ant/antlibs/svn/trunk/docs/tagdiff.html (original)
+++ ant/antlibs/svn/trunk/docs/tagdiff.html Tue May 5 13:11:49 2009
@@ -43,10 +43,19 @@
-----> tags
|
|
- ----------> tag1
- ----------> tag2
+ ----------> fromTag
+ ----------> toTag
+ -----> branches
+ |
+ |
+ ----------> fromBranch
+ ----------> toBranch
</pre>
+<p>It is possible to compare two branches, two tags or tags and
+ branches. The magic name "trunk" can be used in as from* or to* in
+ order to compare a tag/branch to trunk.</p>
+
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -55,14 +64,30 @@
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
- <td valign="top">tag1</td>
+ <td valign="top">fromTag</td>
<td valign="top">The first tag.</td>
- <td align="center" valign="top">Yes.</td>
+ <td align="center" valign="top" rowspan="3">One of the three.</td>
</tr>
<tr>
- <td valign="top">tag2</td>
+ <td valign="top">fromBranch</td>
+ <td valign="top">The first branch.</td>
+ </tr>
+ <tr>
+ <td valign="top">tag1</td>
+ <td valign="top"><b>Deprecated.</b> Equivalent to fromTag.</td>
+ </tr>
+ <tr>
+ <td valign="top">toTag</td>
<td valign="top">The second tag.</td>
- <td align="center" valign="top">No, defaults to "trunk/"</td>
+ <td align="center" valign="top" rowspan="3">No, default is "trunk/"</td>
+ </tr>
+ <tr>
+ <td valign="top">toBranch</td>
+ <td valign="top">The second branch.</td>
+ </tr>
+ <tr>
+ <td valign="top">tag2</td>
+ <td valign="top"><b>Deprecated.</b> Equivalent to toTag.</td>
</tr>
<tr>
<td valign="top">destfile</td>
@@ -97,8 +122,8 @@
<tagdiff failonerror="true"
baseURL="http://svn.apache.org/repos/asf/jakarta/bcel/"
destfile="diff.xml"
- tag1="initial"
- tag2="BCEL_5_0"
+ fromTag="initial"
+ toTag="BCEL_5_0"
/>
</pre>
@@ -111,8 +136,8 @@
<tagdiff failonerror="true"
baseURL="http://svn.apache.org/repos/asf/jakarta/bcel/"
destfile="diff.xml"
- tag1="BCEL_5_0"
- tag2="trunk"
+ fromTag="BCEL_5_0"
+ toBranch="trunk"
/>
</pre>
@@ -125,11 +150,11 @@
<tagdiff failonerror="true"
baseURL="http://svn.apache.org/repos/asf/jakarta/bcel/"
destfile="diff.xml"
- tag1="BCEL_5_0"
+ fromTag="BCEL_5_0"
/>
</pre>
-<p>Does the same, using <code>trunk</code> as <code>tag2</code>
+<p>Does the same, using <code>trunk</code> as <code>to*</code>
implicitly.</p>
<h4>Generate Report</h4>
@@ -150,7 +175,7 @@
<h4>(Shortened) Example Output</h4>
<pre>
<?xml version="1.0" encoding="UTF-8"?>
-<tagdiff tag1="BCEL_5_0"
svnurl="http://svn.apache.org/repos/asf/jakarta/bcel/" >
+<tagdiff fromTag="BCEL_5_0"
svnurl="http://svn.apache.org/repos/asf/jakarta/bcel/" >
<path>
<name><![CDATA[default.properties]]></name>
<action>added</action>
Modified: ant/antlibs/svn/trunk/src/etc/diff.xsl
URL:
http://svn.apache.org/viewvc/ant/antlibs/svn/trunk/src/etc/diff.xsl?rev=771707&r1=771706&r2=771707&view=diff
==============================================================================
--- ant/antlibs/svn/trunk/src/etc/diff.xsl (original)
+++ ant/antlibs/svn/trunk/src/etc/diff.xsl Tue May 5 13:11:49 2009
@@ -60,7 +60,7 @@
<h1>
<a name="top"><xsl:value-of select="$title"/></a>
</h1>
- diff between <xsl:value-of select="@start"/><xsl:value-of
select="@tag1"/> and <xsl:value-of select="@end"/><xsl:value-of select="@tag2"/>
+ diff between <xsl:value-of select="@start"/><xsl:value-of
select="@fromTag"/><xsl:value-of select="@fromBranch"/> and <xsl:value-of
select="@end"/><xsl:value-of select="@toTag"/><xsl:value-of select="@toBranch"/>
<p align="right">Designed for use with <a
href="http://ant.apache.org/">Apache Ant</a>.</p>
<hr size="2"/>
<a name="TOP"/>
Modified: ant/antlibs/svn/trunk/src/main/org/apache/ant/svn/SvnTagDiff.java
URL:
http://svn.apache.org/viewvc/ant/antlibs/svn/trunk/src/main/org/apache/ant/svn/SvnTagDiff.java?rev=771707&r1=771706&r2=771707&view=diff
==============================================================================
--- ant/antlibs/svn/trunk/src/main/org/apache/ant/svn/SvnTagDiff.java (original)
+++ ant/antlibs/svn/trunk/src/main/org/apache/ant/svn/SvnTagDiff.java Tue May
5 13:11:49 2009
@@ -44,18 +44,39 @@
* -----> tags
* |
* |
- * ----------> tag1
- * ----------> tag2
+ * ----------> fromTag
+ * ----------> toTag
+ * -----> branches
+ * |
+ * |
+ * ----------> fromBranch
+ * ----------> toBranch
* </pre>
*
- * It produces an XML output representing the list of changes.
+ * <p>It produces an XML output representing the list of changes.</p>
+ *
+ * <p>The task will compare any combination of branches and tags. To
+ * compare a newer branch to an older tag use the fromTag and toBranch
+ * attributes. To compare two tags use fromTag and toTag All
+ * combinations work as expected.</p>
+ *
+ * <p>You can specify the trunk for any of the four branch/tag
+ * attibutes by using the special value "trunk" (without the quotes).</p>
+ *
+ * <p>The older syntax using tag1 tag2 attributes is deprecated (but
+ * it still works)</p>
+ *
* <PRE>
* <!-- Root element -->
* <!ELEMENT tagdiff ( paths? ) >
* <!-- First tag -->
- * <!ATTLIST tagdiff tag1 NMTOKEN #IMPLIED >
+ * <!ATTLIST tagdiff fromTag NMTOKEN #IMPLIED >
* <!-- Second tag -->
- * <!ATTLIST tagdiff tag2 NMTOKEN #IMPLIED >
+ * <!ATTLIST tagdiff toTag NMTOKEN #IMPLIED >
+ * <!-- First branch -->
+ * <!ATTLIST tagdiff fromBranch NMTOKEN #IMPLIED >
+ * <!-- Second branch -->
+ * <!ATTLIST tagdiff toBranch NMTOKEN #IMPLIED >
* <!-- Subversion BaseURL -->
* <!ATTLIST tagdiff svnurl NMTOKEN #IMPLIED >
*
@@ -78,13 +99,20 @@
/**
* The earliest revision from which diffs are to be included in the report.
*/
- private String tag1;
+ private String fromTag;
/**
* The latest revision from which diffs are to be included in the report.
*/
- private String tag2;
-
+ private String toTag;
+ /**
+ * The earliest revision from which diffs are to be included in the report.
+ */
+ private String fromBranch;
+ /**
+ * The latest revision from which diffs are to be included in the report.
+ */
+ private String toBranch;
/**
* The file in which to write the diff report.
*/
@@ -94,23 +122,90 @@
* Base URL.
*/
private String baseURL;
+ /**
+ * the name of the older branch or tag
+ */
+ private String fromCopy;
+ /**
+ * the name of the newer branch or tag
+ */
+ private String toCopy;
+ /**
+ * Base the name of the attribute in the output
+ * e.g "fromBranch" or "fromTag" for the older copy
+ */
+ private String fromName;
+ /**
+ * Base the name of the attribute in the output
+ * e.g "toBranch" or "toTag" for the newer copy
+ */
+ private String toName;
+ /**
+ * Base the name of the directory of branches or tags
+ * e.g "branches/" or "tags/" for the older copy
+ */
+ private String fromDir;
+ /**
+ * Base the name of the directory of branches or tags
+ * e.g "branches/" or "tags/" for the newer copy
+ */
+ private String toDir;
+
+
+ /**
+ * Set the first tag.
+ *
+ * @param s the first tag.
+ */
+ public void setFromTag(String s) {
+ fromTag = s;
+ }
+
+ /**
+ * Set the second tag.
+ *
+ * @param s the second tag.
+ */
+ public void setToTag(String s) {
+ toTag = s;
+ }
/**
* Set the first tag.
*
* @param s the first tag.
+ * @deprecated use fromTag
*/
public void setTag1(String s) {
- tag1 = s;
+ setFromTag(s);
}
/**
* Set the second tag.
*
* @param s the second tag.
+ * @deprecated use toTag
*/
public void setTag2(String s) {
- tag2 = s;
+ setToTag(s);
+ }
+
+ /**
+ * Set the first branch.
+ *
+ * @param s the first branch.
+ */
+ public void setFromBranch(String s) {
+ fromBranch = s;
+ }
+
+ /**
+ * Set the second branch.
+ *
+ * @param s the second branch.
+ */
+ public void setToBranch(String s) {
+ toBranch = s;
}
/**
@@ -143,28 +238,19 @@
// validate the input parameters
validate();
+ // sort out whats tags and whats branches
+ this.fromCopy = fromTag !=null ? fromTag : fromBranch;
+ this.toCopy = toTag != null ? toTag : toBranch;
+ this.fromName = fromTag != null ? "fromTag" : "fromBranch";
+ this.toName = toTag != null ? "toTag" : "toBranch";
+ this.fromDir = fromTag != null ? "tags/" : "branches/";
+ this.toDir = toTag != null ? "tags/" : "branches/";
+
// build the rdiff command
setSubCommand("diff");
addSubCommandArgument("--no-diff-deleted");
- if (tag1.equals("trunk") || tag1.equals("trunk/")) {
- addSubCommandArgument(baseURL + "trunk/");
- } else {
- if (tag1.endsWith("/")) {
- addSubCommandArgument(baseURL + "tags/" + tag1);
- } else {
- addSubCommandArgument(baseURL + "tags/" + tag1 + "/");
- }
- }
- if (tag2 == null || tag2.equals("trunk") || tag2.equals("trunk/")) {
- addSubCommandArgument(baseURL + "trunk/");
- } else {
- if (tag2.endsWith("/")) {
- addSubCommandArgument(baseURL + "tags/" + tag2);
- } else {
- addSubCommandArgument(baseURL + "tags/" + tag2 + "/");
- }
- }
-
+ addDiffArguments();
+
File tmpFile = null;
try {
tmpFile =
@@ -180,8 +266,8 @@
// write the revision diff
SvnDiffHandler.writeDiff(mydestfile, entries, "tagdiff",
- "tag1", tag1, "tag2",
- tag2 == null ? "trunk" : tag2,
+ fromName, fromCopy, toName,
+ toCopy,
baseURL);
} finally {
if (tmpFile != null) {
@@ -190,6 +276,28 @@
}
}
+ private void addDiffArguments(){
+ if (fromCopy.equals("trunk") || fromCopy.equals("trunk/")) {
+ addSubCommandArgument(baseURL + "trunk/");
+ } else {
+ if (fromCopy.endsWith("/")) {
+ addSubCommandArgument(baseURL + fromDir + fromCopy);
+ } else {
+ addSubCommandArgument(baseURL + fromDir + fromCopy + "/");
+ }
+ }
+ if (toCopy == null || toCopy.equals("trunk")
+ || toCopy.equals("trunk/")) {
+ addSubCommandArgument(baseURL + "trunk/");
+ } else {
+ if (toCopy.endsWith("/")) {
+ addSubCommandArgument(baseURL + toDir + toCopy);
+ } else {
+ addSubCommandArgument(baseURL + toDir + toCopy + "/");
+ }
+ }
+ }
+
/**
* Validate the parameters specified for task.
*
@@ -200,8 +308,8 @@
throw new BuildException("Destfile must be set.");
}
- if (null == tag1) {
- throw new BuildException("tag1 must be set.");
+ if (null == fromTag && null== fromBranch) {
+ throw new BuildException("fromTag or fromBranch must be set.");
}
if (null == baseURL) {