ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r771731 - in /ant/antlibs/svn/trunk/src: main/org/apache/ant/svn/SvnTagDiff.java tests/junit/org/apache/ant/svn/SvnTagDiffTest.java
Date Tue, 05 May 2009 14:03:11 GMT
Author: bodewig
Date: Tue May  5 14:03:11 2009
New Revision: 771731

URL: http://svn.apache.org/viewvc?rev=771731&view=rev
Log:
Adapt tests to PR 47105, fix handling of implicit trunk "tags"

Modified:
    ant/antlibs/svn/trunk/src/main/org/apache/ant/svn/SvnTagDiff.java
    ant/antlibs/svn/trunk/src/tests/junit/org/apache/ant/svn/SvnTagDiffTest.java

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=771731&r1=771730&r2=771731&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 14:03:11
2009
@@ -91,6 +91,9 @@
  */
 public class SvnTagDiff extends AbstractSvnTask {
 
+    private static final String TRUNK = "trunk";
+    private static final String TRUNK_SLASH = TRUNK + "/";
+
     /**
      * Used to create the temp file for svn log
      */
@@ -240,7 +243,8 @@
 
         // sort out whats tags and whats branches
         this.fromCopy = fromTag !=null ? fromTag : fromBranch;
-        this.toCopy = toTag != null ? toTag : toBranch;
+        this.toCopy = toTag != null ? toTag 
+            : toBranch != null ? toBranch : TRUNK;
         this.fromName = fromTag != null ? "fromTag" : "fromBranch";
         this.toName = toTag != null ? "toTag" : "toBranch";
         this.fromDir = fromTag != null ? "tags/" : "branches/";
@@ -277,8 +281,8 @@
     }
 
     private void addDiffArguments(){
-        if (fromCopy.equals("trunk") || fromCopy.equals("trunk/")) {
-            addSubCommandArgument(baseURL + "trunk/");
+        if (fromCopy.equals(TRUNK) || fromCopy.equals(TRUNK_SLASH)) {
+            addSubCommandArgument(baseURL + TRUNK_SLASH);
         } else {
             if (fromCopy.endsWith("/")) {
                 addSubCommandArgument(baseURL + fromDir + fromCopy);
@@ -286,9 +290,8 @@
                 addSubCommandArgument(baseURL + fromDir + fromCopy + "/");
             }
         }
-        if (toCopy == null || toCopy.equals("trunk")
-            || toCopy.equals("trunk/")) {
-            addSubCommandArgument(baseURL + "trunk/");
+        if (toCopy.equals(TRUNK) || toCopy.equals(TRUNK_SLASH)) {
+            addSubCommandArgument(baseURL + TRUNK_SLASH);
         } else {
             if (toCopy.endsWith("/")) {
                 addSubCommandArgument(baseURL + toDir + toCopy);

Modified: ant/antlibs/svn/trunk/src/tests/junit/org/apache/ant/svn/SvnTagDiffTest.java
URL: http://svn.apache.org/viewvc/ant/antlibs/svn/trunk/src/tests/junit/org/apache/ant/svn/SvnTagDiffTest.java?rev=771731&r1=771730&r2=771731&view=diff
==============================================================================
--- ant/antlibs/svn/trunk/src/tests/junit/org/apache/ant/svn/SvnTagDiffTest.java (original)
+++ ant/antlibs/svn/trunk/src/tests/junit/org/apache/ant/svn/SvnTagDiffTest.java Tue May 
5 14:03:11 2009
@@ -49,16 +49,16 @@
 
     public void testDiffWithExplicitTrunk() throws IOException {
         String log = executeTargetAndReadLogFully("diff-with-explicit-trunk");
-        assertDiffWithTrunk(log);
+        assertDiffWithTrunk(log, "toTag");
     }
 
     public void testDiffWithImplicitTrunk() throws IOException {
         String log = executeTargetAndReadLogFully("diff-with-implicit-trunk");
-        assertDiffWithTrunk(log);
+        assertDiffWithTrunk(log, "toBranch");
     }
 
-    private static void assertDiffWithTrunk(String log) {
-        assertAttributes(log, "10_BETA1", "trunk");
+    private static void assertDiffWithTrunk(String log, String tag2Name) {
+        assertAttributes(log, "10_BETA1", tag2Name, "trunk");
         assertAdded(log);
         assertModified(log);
         assertDeleted(log);
@@ -78,14 +78,21 @@
 
     private static final void assertAttributes(String log, String tag1,
                                                String tag2) {
+        assertAttributes(log, tag1, "toTag", tag2);
+    }
+
+    private static final void assertAttributes(String log, String tag1,
+                                               String tag2Name, String tag2) {
         int start = log.indexOf("<tagdiff");
         Assert.assertTrue(start > -1);
         int end = log.indexOf(">", start);
         Assert.assertTrue(end > -1);
-        Assert.assertTrue(log.indexOf("tag1=\"" + tag1 + "\"", start) > -1);
-        Assert.assertTrue(log.indexOf("tag1=\"" + tag1 + "\"", start) < end);
-        Assert.assertTrue(log.indexOf("tag2=\"" + tag2 + "\"", start) > -1);
-        Assert.assertTrue(log.indexOf("tag2=\"" + tag2 + "\"", start) < end);
+        Assert.assertTrue(log.indexOf("fromTag=\"" + tag1 + "\"", start) > -1);
+        Assert.assertTrue(log.indexOf("fromTag=\"" + tag1 + "\"", start) < end);
+        Assert.assertTrue(log.indexOf(tag2Name + "=\"" + tag2 + "\"",
+                                      start) > -1);
+        Assert.assertTrue(log.indexOf(tag2Name + "=\"" + tag2 + "\"",
+                                      start) < end);
         Assert.assertTrue(log.indexOf("svnurl=\"http://svn.apache.org/",
                                       start) > -1);
         Assert.assertTrue(log.indexOf("svnurl=\"http://svn.apache.org/",



Mime
View raw message