subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1499308 - in /subversion/trunk/subversion/bindings/javahl: native/RevisionRange.cpp src/org/apache/subversion/javahl/types/RevisionRange.java tests/org/apache/subversion/javahl/BasicTests.java
Date Wed, 03 Jul 2013 10:22:08 GMT
Author: brane
Date: Wed Jul  3 10:22:08 2013
New Revision: 1499308

URL: http://svn.apache.org/r1499308
Log:
Add inheritance info to JavaHL's RevisionRange type.

* subversion/bindings/javahl/src/org/apache/subversion/javahl/types/RevisionRange.java
  (RevisionRange.serialVersionUID): Updated.
  (RevisionRange.inheritable): New private member.
  (RevisionRange.RevisionRange): Updated construcors and parsers.
  (RevisionRange.isInheritable): New public method.
  (RevisionRange.toString): Note inheritable flag in returned string.
  (RevisionRange.hashCode, RevisionRange.equals): Use inheritable flag.

* subversion/bindings/javahl/native/RevisionRange.cpp
  (RevisionRange::makeJRevisionRange): Update Java object construction.

* subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
  (BasicTests.testMergeinfoParser): Test non-inheritable ranges.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/RevisionRange.cpp
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/RevisionRange.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java

Modified: subversion/trunk/subversion/bindings/javahl/native/RevisionRange.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/RevisionRange.cpp?rev=1499308&r1=1499307&r2=1499308&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/RevisionRange.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/RevisionRange.cpp Wed Jul  3 10:22:08
2013
@@ -112,13 +112,14 @@ RevisionRange::makeJRevisionRange(svn_me
     static jmethodID rangeCtor = 0;
     if (rangeCtor == 0)
     {
-        rangeCtor = env->GetMethodID(rangeClazz, "<init>", "(JJ)V");
+        rangeCtor = env->GetMethodID(rangeClazz, "<init>", "(JJZ)V");
         if (JNIUtil::isJavaExceptionThrown())
             return NULL;
     }
     jobject jrange = env->NewObject(rangeClazz, rangeCtor,
-                                    (jlong) range->start,
-                                    (jlong) range->end);
+                                    jlong(range->start),
+                                    jlong(range->end),
+                                    jboolean(range->inheritable));
     if (JNIUtil::isJavaExceptionThrown())
         return NULL;
 

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/RevisionRange.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/RevisionRange.java?rev=1499308&r1=1499307&r2=1499308&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/RevisionRange.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/RevisionRange.java
Wed Jul  3 10:22:08 2013
@@ -36,25 +36,34 @@ public class RevisionRange implements Co
     // http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf
     // http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/version.html#6678
     // http://java.sun.com/javase/6/docs/platform/serialization/spec/version.html#6678
-    private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 2L;
 
     private Revision from;
     private Revision to;
+    private boolean inheritable;
 
     /**
      * Creates a new instance.  Called by native library.
      */
-    @SuppressWarnings("unused")
-    private RevisionRange(long from, long to)
+    protected RevisionRange(long from, long to, boolean inhertiable)
     {
         this.from = Revision.getInstance(from);
         this.to = Revision.getInstance(to);
+        this.inheritable = inheritable;
+    }
+
+    public RevisionRange(Revision from, Revision to, boolean inhertiable)
+    {
+        this.from = from;
+        this.to = to;
+        this.inheritable = inheritable;
     }
 
     public RevisionRange(Revision from, Revision to)
     {
         this.from = from;
         this.to = to;
+        this.inheritable = true;
     }
 
     /**
@@ -70,6 +79,11 @@ public class RevisionRange implements Co
             return;
         }
 
+        this.inheritable = !revisionElement.endsWith("*");
+        if (!this.inheritable)
+            revisionElement =
+                revisionElement.substring(0, revisionElement.length() - 1);
+
         int hyphen = revisionElement.indexOf('-');
         if (hyphen > 0)
         {
@@ -113,14 +127,20 @@ public class RevisionRange implements Co
         return to;
     }
 
+    public boolean isInheritable()
+    {
+        return inheritable;
+    }
+
     public String toString()
     {
         if (from != null && to != null)
         {
-            if (from.equals(to))
-                return from.toString();
-            else
-                return from.toString() + '-' + to.toString();
+            String rep = (from.equals(to) ? from.toString()
+                          : from.toString() + '-' + to.toString());
+            if (!inheritable)
+                return rep + '*';
+            return rep;
         }
         return super.toString();
     }
@@ -138,7 +158,7 @@ public class RevisionRange implements Co
     public int hashCode()
     {
         final int prime = 31;
-        int result = 1;
+        int result = (inheritable ? 1 : 2);
         result = prime * result + ((from == null) ? 0 : from.hashCode());
         result = prime * result + ((to == null) ? 0 : to.hashCode());
         return result;
@@ -178,7 +198,7 @@ public class RevisionRange implements Co
             return false;
         }
 
-        return true;
+        return (inheritable == other.inheritable);
     }
 
     /**
@@ -192,5 +212,6 @@ public class RevisionRange implements Co
         Revision other = (range).getFromRevision();
         return RevisionRange.getRevisionAsLong(this.getFromRevision())
             .compareTo(RevisionRange.getRevisionAsLong(other));
+        // NOTE: Explicitly ignores inheritable state.
     }
 }

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java?rev=1499308&r1=1499307&r2=1499308&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
Wed Jul  3 10:22:08 2013
@@ -251,16 +251,17 @@ public class BasicTests extends SVNTests
     public void testMergeinfoParser() throws Throwable
     {
         String mergeInfoPropertyValue =
-            "/trunk:1-300,305,307,400-405\n/branches/branch:308-400";
+            "/trunk:1-300,305*,307,400-405*\n" +
+            "/branches/branch:308-400";
         Mergeinfo info = new Mergeinfo(mergeInfoPropertyValue);
         Set<String> paths = info.getPaths();
         assertEquals(2, paths.size());
         List<RevisionRange> trunkRange = info.getRevisionRange("/trunk");
         assertEquals(4, trunkRange.size());
         assertEquals("1-300", trunkRange.get(0).toString());
-        assertEquals("305", trunkRange.get(1).toString());
+        assertEquals("305*", trunkRange.get(1).toString());
         assertEquals("307", trunkRange.get(2).toString());
-        assertEquals("400-405", trunkRange.get(3).toString());
+        assertEquals("400-405*", trunkRange.get(3).toString());
         List<RevisionRange> branchRange =
             info.getRevisionRange("/branches/branch");
         assertEquals(1, branchRange.size());



Mime
View raw message