subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r918579 - in /subversion/trunk/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/ src/org/apache/subversion/javahl/callback/ src/org/tigris/subversion/javahl/ tests/org/apache/subversion/javahl/
Date Wed, 03 Mar 2010 17:11:23 GMT
Author: hwright
Date: Wed Mar  3 17:11:22 2010
New Revision: 918579

URL: http://svn.apache.org/viewvc?rev=918579&view=rev
Log:
JavaHL: Update a callback interface to return a Set in place of an array.

[ in subversion/bindings/javahl/ ]
* tests/org/apache/subversion/javahl/BasicTests.java:
  Update test implemetations to expect the new API.

* native/LogMessageCallback.cpp
  (singleMessage): Return a set of ChangePaths, in place of the array.

* src/org/tigris/subversion/javahl/ChangePath.java:
  Make this class Comparable, for backward compat.

* src/org/tigris/subversion/javahl/SVNClient.java
  (logMessages, getMergeinfoLog): Update compat wrappers for the new API.

* src/org/apache/subversion/javahl/LogMessage.java
  (LogMessage): Update constructor to take the new type.
  (changedPaths): Use the Set type.
  (getChangedPaths): Return the new type.

* src/org/apache/subversion/javahl/callback/LogMessageCallback.java
  (singleMessage): Update the interface to use a Set of change paths.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/LogMessage.java
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/LogMessageCallback.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/ChangePath.java
    subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java

Modified: subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp?rev=918579&r1=918578&r2=918579&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp Wed Mar  3 17:11:22
2010
@@ -81,8 +81,7 @@
 
       sm_mid = env->GetMethodID(clazz,
                                 "singleMessage",
-                                "([L"JAVA_PACKAGE"/ChangePath;"
-                                "JLjava/util/Map;Z)V");
+                                "(Ljava/util/Set;JLjava/util/Map;Z)V");
       if (JNIUtil::isJavaExceptionThrown())
         return SVN_NO_ERROR;
 
@@ -105,29 +104,19 @@
         return SVN_NO_ERROR;
     }
 
-  jobjectArray jChangedPaths = NULL;
+  jobject jChangedPaths = NULL;
   if (log_entry->changed_paths)
     {
-      apr_array_header_t *sorted_paths;
-      int i;
+      apr_hash_index_t *hi;
+      std::vector<jobject> jcps;
 
-      /* Get an array of sorted hash keys. */
-      sorted_paths = svn_sort__hash(log_entry->changed_paths,
-                                    svn_sort_compare_items_as_paths,
-                                    pool);
-
-      jChangedPaths = env->NewObjectArray(sorted_paths->nelts,
-                                          clazzCP,
-                                          NULL);
-
-      for (i = 0; i < sorted_paths->nelts; ++i)
+      for (hi = apr_hash_first(pool, log_entry->changed_paths);
+           hi;
+           hi = apr_hash_next(hi))
         {
-          svn_sort__item_t *item = &(APR_ARRAY_IDX(sorted_paths, i,
-                                                   svn_sort__item_t));
-          const char *path = (const char *)item->key;
-          svn_log_changed_path2_t *log_item
-            = (svn_log_changed_path2_t *)
-            apr_hash_get(log_entry->changed_paths, item->key, item->klen);
+          const char *path = (const char *) svn_apr_hash_index_key(hi);
+          svn_log_changed_path2_t *log_item =
+                    (svn_log_changed_path2_t *) svn_apr_hash_index_val(hi);
 
           jstring jpath = JNIUtil::makeJString(path);
           if (JNIUtil::isJavaExceptionThrown())
@@ -147,13 +136,7 @@
           if (JNIUtil::isJavaExceptionThrown())
             return SVN_NO_ERROR;
 
-          env->SetObjectArrayElement(jChangedPaths, i, cp);
-          if (JNIUtil::isJavaExceptionThrown())
-            return SVN_NO_ERROR;
-
-          env->DeleteLocalRef(cp);
-          if (JNIUtil::isJavaExceptionThrown())
-            return SVN_NO_ERROR;
+          jcps.push_back(cp);
 
           env->DeleteLocalRef(jpath);
           if (JNIUtil::isJavaExceptionThrown())
@@ -163,6 +146,8 @@
           if (JNIUtil::isJavaExceptionThrown())
             return SVN_NO_ERROR;
         }
+
+      jChangedPaths = CreateJ::Set(jcps);
     }
 
   jobject jrevprops = NULL;

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/LogMessage.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/LogMessage.java?rev=918579&r1=918578&r2=918579&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/LogMessage.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/LogMessage.java
Wed Mar  3 17:11:22 2010
@@ -24,6 +24,8 @@
 package org.apache.subversion.javahl;
 
 import java.util.Date;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * This class describes a single subversion revision with log message,
@@ -71,7 +73,7 @@
      * SVNClientInterface.logMessages is used with discoverPaths
      * true).
      */
-    private ChangePath[] changedPaths;
+    private Set<ChangePath> changedPaths;
 
     /**
      * This constructor is the original constructor from Subversion
@@ -85,7 +87,7 @@
      *                     of microseconds since 00:00:00 January 1,
      *                     1970 UTC
      */
-    LogMessage(ChangePath[] cp, long r, String a, Date d, String m)
+    LogMessage(Set<ChangePath> cp, long r, String a, Date d, String m)
     {
         changedPaths = cp;
         revision = r;
@@ -106,7 +108,7 @@
      * @param message      the log message text
      * @since 1.5
      */
-    LogMessage(ChangePath[] cp, long r, String a, long t, String m)
+    LogMessage(Set<ChangePath> cp, long r, String a, long t, String m)
     {
         changedPaths = cp;
         revision = r;
@@ -191,7 +193,7 @@
      * Returns the changes items by this commit
      * @return the changes items by this commit
      */
-    public ChangePath[] getChangedPaths()
+    public Set<ChangePath> getChangedPaths()
     {
         return changedPaths;
     }

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/LogMessageCallback.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/LogMessageCallback.java?rev=918579&r1=918578&r2=918579&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/LogMessageCallback.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/LogMessageCallback.java
Wed Mar  3 17:11:22 2010
@@ -26,6 +26,7 @@
 import org.apache.subversion.javahl.ChangePath;
 
 import java.util.Map;
+import java.util.Set;
 
 /**
  * This interface is used to receive every log message for the log
@@ -49,7 +50,7 @@
     /**
      * The method will be called for every log message.
      *
-     * @param changedPaths   the paths that were changed
+     * @param changedPaths   a set of the paths that were changed
      * @param revision       the revision of the commit
      * @param revprops       All of the requested revision properties,
      *                       possibly including svn:date, svn:author,
@@ -57,7 +58,7 @@
      * @param hasChildren    when merge sensitive option was requested,
      *                       whether or not this entry has child entries.
      */
-    public void singleMessage(ChangePath[] changedPaths,
+    public void singleMessage(Set<ChangePath> changedPaths,
                               long revision,
                               Map<String, byte[]> revprops,
                               boolean hasChildren);

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/ChangePath.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/ChangePath.java?rev=918579&r1=918578&r2=918579&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/ChangePath.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/ChangePath.java
Wed Mar  3 17:11:22 2010
@@ -23,7 +23,7 @@
 
 package org.tigris.subversion.javahl;
 
-public class ChangePath implements java.io.Serializable
+public class ChangePath implements java.io.Serializable, Comparable
 {
     // Update the serialVersionUID when there is a incompatible change
     // made to this class.  See any of the following, depending upon
@@ -62,6 +62,11 @@
              aChangePath.getNodeKind());
     }
 
+    public int compareTo(Object other)
+    {
+        return path.compareTo(((ChangePath)other).path);
+    }
+
     /** Path of commited item */
     private String path;
 

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java?rev=918579&r1=918578&r2=918579&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java
Wed Mar  3 17:11:22 2010
@@ -28,6 +28,7 @@
 import java.io.OutputStream;
 
 import java.util.Map;
+import java.util.Set;
 import java.util.HashMap;
 import java.util.List;
 import java.util.HashSet;
@@ -469,7 +470,7 @@
             }
 
             public void singleMessage(
-                    org.apache.subversion.javahl.ChangePath[] aChangedPaths,
+                    Set<org.apache.subversion.javahl.ChangePath> aChangedPaths,
                     long revision, Map<String, byte[]> revprops,
                     boolean hasChildren)
             {
@@ -479,12 +480,16 @@
                 
                 if (aChangedPaths != null)
                 {
-                    changedPaths = new ChangePath[aChangedPaths.length];
+                    changedPaths = new ChangePath[aChangedPaths.size()];
 
-                    for (int i = 0; i < aChangedPaths.length; i++)
+                    int i = 0;
+                    for (org.apache.subversion.javahl.ChangePath cp
+                                                            : aChangedPaths)
                     {
-                        changedPaths[i] = new ChangePath(aChangedPaths[i]);
+                        changedPaths[i] = new ChangePath(cp);
+                        i++;
                     }
+                    Arrays.sort(changedPaths);
                 }
                 else
                 {
@@ -1342,18 +1347,22 @@
             implements org.apache.subversion.javahl.callback.LogMessageCallback
         {
             public void singleMessage(
-                    org.apache.subversion.javahl.ChangePath[] aChangedPaths,
-                    long revision, Map revprops, boolean hasChildren)
+                    Set<org.apache.subversion.javahl.ChangePath> aChangedPaths,
+                    long revision, Map<String, byte[]> revprops,
+                    boolean hasChildren)
             {
                 ChangePath[] changedPaths;
 
                 if (aChangedPaths != null)
                 {
-                    changedPaths = new ChangePath[aChangedPaths.length];
+                    changedPaths = new ChangePath[aChangedPaths.size()];
 
-                    for (int i = 0; i < aChangedPaths.length; i++)
+                    int i = 0;
+                    for (org.apache.subversion.javahl.ChangePath cp
+                                                             : aChangedPaths)
                     {
-                        changedPaths[i] = new ChangePath(aChangedPaths[i]);
+                        changedPaths[i] = new ChangePath(cp);
+                        i++;
                     }
                 }
                 else

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=918579&r1=918578&r2=918579&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 Mar  3 17:11:22 2010
@@ -2119,12 +2119,14 @@
         assertEquals("wrong revision", 1, lm[0].getRevisionNumber());
         assertEquals("wrong user", "jrandom", lm[0].getAuthor());
         assertNotNull("changed paths set", lm[0].getChangedPaths());
-        ChangePath cp[] = lm[0].getChangedPaths();
-        assertEquals("wrong number of chang pathes", 20, cp.length);
-        assertEquals("wrong path", "/A", cp[0].getPath());
-        assertEquals("wrong copy source rev", -1, cp[0].getCopySrcRevision());
-        assertNull("wrong copy source path", cp[0].getCopySrcPath());
-        assertEquals("wrong action", 'A', cp[0].getAction());
+        Set<ChangePath> cp = lm[0].getChangedPaths();
+        assertEquals("wrong number of chang pathes", 20, cp.size());
+        ChangePath changedApath = cp.toArray(new ChangePath[1])[0];
+        assertNotNull("wrong path", changedApath);
+        assertEquals("wrong copy source rev", -1,
+                      changedApath.getCopySrcRevision());
+        assertNull("wrong copy source path", changedApath.getCopySrcPath());
+        assertEquals("wrong action", 'A', changedApath.getAction());
         assertEquals("wrong time with getTimeMicros()",
                      lm[0].getTimeMicros()/1000,
                      lm[0].getDate().getTime());
@@ -2360,8 +2362,9 @@
 
             List<Long> revList = new ArrayList<Long>();
 
-            public void singleMessage(ChangePath[] changedPaths, long revision,
-                    Map<String, byte[]> revprops, boolean hasChildren) {
+            public void singleMessage(Set<ChangePath> changedPaths,
+                    long revision, Map<String, byte[]> revprops,
+                    boolean hasChildren) {
                 revList.add(new Long(revision));
             }
 
@@ -3460,7 +3463,7 @@
         {
             Map<String, byte[]> revprops;
 
-            public void singleMessage(ChangePath[] changedPaths,
+            public void singleMessage(Set<ChangePath> changedPaths,
                                       long revision,
                                       Map<String, byte[]> revprops,
                                       boolean hasChildren)
@@ -3759,7 +3762,7 @@
         {
             private List<LogMessage> messages = new ArrayList<LogMessage>();
 
-            public void singleMessage(ChangePath[] changedPaths,
+            public void singleMessage(Set<ChangePath> changedPaths,
                                       long revision,
                                       Map<String, byte[]> revprops,
                                       boolean hasChildren)



Mime
View raw message