subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r917858 - in /subversion/trunk/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/ src/org/tigris/subversion/javahl/ tests/org/apache/subversion/javahl/
Date Tue, 02 Mar 2010 03:32:49 GMT
Author: hwright
Date: Tue Mar  2 03:32:48 2010
New Revision: 917858

URL: http://svn.apache.org/viewvc?rev=917858&view=rev
Log:
JavaHL: Change the return type of the suggested merge API to a Set of Strings.

[ in subversion/bindings/javahl/ ]
* tests/org/apache/subversion/javahl/BasicTests.java
  (assertExpectedSuggestion, testBasicMerge, testRecordOnlyMerge,
   setupAndPerformMerge): Update expected returned type.

* native/CreateJ.cpp,
  native/CreateJ.h
  (StringSet): New.

* native/SVNClient.h,
  native/SVNClient.cpp
  (suggestMergeSources): Update return type, and return a constructed Set.

* native/org_apache_subversion_javahl_SVNClient.cpp
  (Java_org_apache_subversion_javahl_SVNClient_suggestMergeSources):
    Update return type.

* src/org/tigris/subversion/javahl/SVNClient.java
  (suggestMergeSources): Update wrapper.

* src/org/apache/subversion/javahl/SVNClient.java
  (suggestMergeSources): Return a Set<String> instead of String[].

* src/org/apache/subversion/javahl/ISVNClient.java
  (suggestMergeSources): Same.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
    subversion/trunk/subversion/bindings/javahl/native/CreateJ.h
    subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
    subversion/trunk/subversion/bindings/javahl/native/SVNClient.h
    subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.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/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp?rev=917858&r1=917857&r2=917858&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp Tue Mar  2 03:32:48 2010
@@ -385,3 +385,54 @@
 
     return jranges;
 }
+
+jobject
+CreateJ::StringSet(apr_array_header_t *strings)
+{
+  JNIEnv *env = JNIUtil::getEnv();
+  jclass clazz = env->FindClass("java/util/HashSet");
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
+  static jmethodID init_mid = 0;
+  if (init_mid == 0)
+    {
+      init_mid = env->GetMethodID(clazz, "<init>", "()V");
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+    }
+
+  static jmethodID add_mid = 0;
+  if (add_mid == 0)
+    {
+      add_mid = env->GetMethodID(clazz, "add", "(Ljava/lang/Object;)Z");
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+    }
+
+  jobject set = env->NewObject(clazz, init_mid);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
+  for (int i = 0; i < strings->nelts; ++i)
+    {
+      const char *str = APR_ARRAY_IDX(strings, i, const char *);
+      jstring jstr = JNIUtil::makeJString(str);
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+        
+      env->CallObjectMethod(set, add_mid, jstr);
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+
+      env->DeleteLocalRef(jstr);
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+    }
+
+  env->DeleteLocalRef(clazz);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
+  return set;
+}

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.h?rev=917858&r1=917857&r2=917858&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.h Tue Mar  2 03:32:48 2010
@@ -50,6 +50,9 @@
   static jobjectArray
   RevisionRangeArray(apr_array_header_t *ranges);
 
+  static jobject
+  StringSet(apr_array_header_t *strings);
+
  protected:
   static jobject
   ConflictVersion(const svn_wc_conflict_version_t *version);

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp?rev=917858&r1=917857&r2=917858&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp Tue Mar  2 03:32:48 2010
@@ -627,7 +627,7 @@
                                    requestPool.pool()), );
 }
 
-jobjectArray
+jobject
 SVNClient::suggestMergeSources(const char *path, Revision &pegRevision)
 {
     SVN::Pool requestPool;
@@ -641,26 +641,7 @@
                                                  ctx, requestPool.pool()),
                 NULL);
 
-    JNIEnv *env = JNIUtil::getEnv();
-    jclass clazz = env->FindClass("java/lang/String");
-    if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-    jobjectArray jsuggestions = env->NewObjectArray(sources->nelts, clazz,
-                                                    NULL);
-    for (int i = 0; i < sources->nelts; ++i)
-    {
-        const char *source = APR_ARRAY_IDX(sources, i, const char *);
-        jstring jpath = JNIUtil::makeJString(source);
-        if (JNIUtil::isJavaExceptionThrown())
-            return NULL;
-
-        env->SetObjectArrayElement(jsuggestions, i, jpath);
-        if (JNIUtil::isJavaExceptionThrown())
-            return NULL;
-    }
-
-    return jsuggestions;
+    return CreateJ::StringSet(sources);
 }
 
 void SVNClient::merge(const char *path1, Revision &revision1,

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.h?rev=917858&r1=917857&r2=917858&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.h Tue Mar  2 03:32:48 2010
@@ -100,7 +100,7 @@
                        Revision &srcPegRevision, bool discoverChangedPaths,
                        svn_depth_t depth, StringArray &revProps,
                        LogMessageCallback *callback);
-  jobjectArray suggestMergeSources(const char *path, Revision &pegRevision);
+  jobject suggestMergeSources(const char *path, Revision &pegRevision);
   void merge(const char *path1, Revision &revision1, const char *path2,
              Revision &revision2, const char *localPath, bool force,
              svn_depth_t depth, bool ignoreAncestry, bool dryRun,

Modified: subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp?rev=917858&r1=917857&r2=917858&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
(original)
+++ subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
Tue Mar  2 03:32:48 2010
@@ -803,7 +803,7 @@
                jignoreUnknownNodeTypes ? true : false, revprops);
 }
 
-JNIEXPORT jobjectArray JNICALL
+JNIEXPORT jobject JNICALL
 Java_org_apache_subversion_javahl_SVNClient_suggestMergeSources
 (JNIEnv *env, jobject jthis, jstring jpath, jobject jpegRevision)
 {

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java?rev=917858&r1=917857&r2=917858&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
Tue Mar  2 03:32:48 2010
@@ -441,7 +441,7 @@
      * @throws ClientException If an error occurs.
      * @since 1.5
      */
-    String[] suggestMergeSources(String path, Revision pegRevision)
+    Set<String> suggestMergeSources(String path, Revision pegRevision)
             throws SubversionException;
 
     /**

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java?rev=917858&r1=917857&r2=917858&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
Tue Mar  2 03:32:48 2010
@@ -396,8 +396,8 @@
     /**
      * @since 1.5
      */
-    public native String[] suggestMergeSources(String path,
-                                               Revision pegRevision)
+    public native Set<String> suggestMergeSources(String path,
+                                                  Revision pegRevision)
             throws SubversionException;
 
     /**

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=917858&r1=917857&r2=917858&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
Tue Mar  2 03:32:48 2010
@@ -1175,7 +1175,8 @@
         try
         {
             return aSVNClient.suggestMergeSources(path,
-                         pegRevision == null ? null : pegRevision.toApache());
+                         pegRevision == null ? null : pegRevision.toApache()
+                     ).toArray(new String[0]);
         }
         catch (org.apache.subversion.javahl.SubversionException ex)
         {

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=917858&r1=917857&r2=917858&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
Tue Mar  2 03:32:48 2010
@@ -994,22 +994,22 @@
     {
         String wcPath = fileToSVNPath(new File(thisTest.getWCPath(),
                                                destPath), false);
-        String[] suggestions = client.suggestMergeSources(wcPath,
-                                                          Revision.WORKING);
+        Set<String> suggestions = client.suggestMergeSources(wcPath,
+                                                             Revision.WORKING);
         assertNotNull(suggestions);
-        assertTrue(suggestions.length >= 1);
-        assertTrue("Unexpected copy source path, expected " +
-                   expectedSrc + ", got " + suggestions[0],
-                   expectedSrc.equals(suggestions[0]));
+        assertTrue(suggestions.size() >= 1);
+        assertTrue("Copy source path not found in suggestions: " +
+                   expectedSrc,
+                   suggestions.contains(expectedSrc));
 
         // Same test using URL
         String url = thisTest.getUrl() + "/" + destPath;
         suggestions = client.suggestMergeSources(url, Revision.HEAD);
         assertNotNull(suggestions);
-        assertTrue(suggestions.length >= 1);
-        assertTrue("Unexpected copy source path, expected " +
-                   expectedSrc + ", got " + suggestions[0],
-                   expectedSrc.equals(suggestions[0]));
+        assertTrue(suggestions.size() >= 1);
+        assertTrue("Copy source path not found in suggestions: " +
+                   expectedSrc,
+                   suggestions.contains(expectedSrc));
 
     }
 
@@ -2422,11 +2422,11 @@
         OneTest thisTest = setupAndPerformMerge();
 
         // Verify that there are now potential merge sources.
-        String[] suggestedSrcs =
+        Set<String> suggestedSrcs =
             client.suggestMergeSources(thisTest.getWCPath() + "/branches/A",
                                        Revision.WORKING);
         assertNotNull(suggestedSrcs);
-        assertEquals(1, suggestedSrcs.length);
+        assertEquals(1, suggestedSrcs.size());
 
         // Test that getMergeinfo() returns null.
         assertNull(client.getMergeinfo(new File(thisTest.getWCPath(), "A")
@@ -2696,11 +2696,11 @@
         OneTest thisTest = setupAndPerformMerge();
 
         // Verify that there are now potential merge sources.
-        String[] suggestedSrcs =
+        Set<String> suggestedSrcs =
             client.suggestMergeSources(thisTest.getWCPath() + "/branches/A",
                                        Revision.WORKING);
         assertNotNull(suggestedSrcs);
-        assertEquals(1, suggestedSrcs.length);
+        assertEquals(1, suggestedSrcs.size());
 
         // Test that getMergeinfo() returns null.
         assertNull(client.getMergeinfo(new File(thisTest.getWCPath(), "A")
@@ -2753,11 +2753,11 @@
         OneTest thisTest = new OneTest();
 
         // Verify that there are initially no potential merge sources.
-        String[] suggestedSrcs =
+        Set<String> suggestedSrcs =
             client.suggestMergeSources(thisTest.getWCPath(),
                                        Revision.WORKING);
         assertNotNull(suggestedSrcs);
-        assertEquals(0, suggestedSrcs.length);
+        assertEquals(0, suggestedSrcs.size());
 
         // create branches directory in the repository (r2)
         addExpectedCommitItem(null, thisTest.getUrl(), "branches",



Mime
View raw message