subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r925343 - in /subversion/trunk/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/ src/org/tigris/subversion/javahl/ tests/org/apache/subversion/javahl/
Date Fri, 19 Mar 2010 17:23:41 GMT
Author: hwright
Date: Fri Mar 19 17:23:40 2010
New Revision: 925343

URL: http://svn.apache.org/viewvc?rev=925343&view=rev
Log:
JavaHL: Enum'ize the ConflictResult-define constants.

[ in subversion/bindings/javahl/ ]
* tests/org/apache/subversion/javahl/BasicTests.java:
  Update tests to use the new enum.

* native/ConflictResolverCallback.cpp
  (javaResultToC): Update for the new type, make sure we delete our local
    reference.
   (javaChoiceToC): Remove.

* native/ConflictResolverCallback.h
  (javaChoiceToC): Remove.

* native/EnumMapper.h,
  native/EnumMapper.cpp
  (toConflictChoice): New.

* native/org_apache_subversion_javahl_SVNClient.cpp
  (Java_org_apache_subversion_javahl_SVNClient_resolve): Map the incoming
    conflict choice.

* src/org/apache/subversion/javahl/ConflictResult.java
  (Choice): New enum, with the contents being the previous constants.
    Update constructor, getters and setters.

* src/org/apache/subversion/javahl/SVNClient.java,
  src/org/apache/subversion/javahl/ISVNClient.java
  (resolve): Update to take a Choice parameters.

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

* src/org/tigris/subversion/javahl/ConflictResult.java
  (toApache): Update wrapper.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/ConflictResolverCallback.cpp
    subversion/trunk/subversion/bindings/javahl/native/ConflictResolverCallback.h
    subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp
    subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h
    subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ConflictResult.java
    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/ConflictResult.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/ConflictResolverCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ConflictResolverCallback.cpp?rev=925343&r1=925342&r2=925343&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ConflictResolverCallback.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/ConflictResolverCallback.cpp Fri Mar
19 17:23:40 2010
@@ -163,7 +163,8 @@ ConflictResolverCallback::javaResultToC(
 
   if (getChoice == 0)
     {
-      getChoice = env->GetMethodID(clazz, "getChoice", "()I");
+      getChoice = env->GetMethodID(clazz, "getChoice",
+                                   "()L"JAVA_PACKAGE"/ConflictResult$Choice;");
       if (JNIUtil::isJavaExceptionThrown() || getChoice == 0)
         return NULL;
     }
@@ -182,39 +183,24 @@ ConflictResolverCallback::javaResultToC(
         return NULL;
     }
 
-  jint jchoice = env->CallIntMethod(jresult, getChoice);
+  jobject jchoice = env->CallObjectMethod(jresult, getChoice);
   if (JNIUtil::isJavaExceptionThrown())
     return NULL;
 
-  jstring jmergedPath =
-    (jstring) env->CallObjectMethod(jresult, getMergedPath);
+  jstring jmergedPath = (jstring) env->CallObjectMethod(jresult, getMergedPath);
   if (JNIUtil::isJavaExceptionThrown())
     return NULL;
+
   JNIStringHolder mergedPath(jmergedPath);
 
-  return svn_wc_create_conflict_result(javaChoiceToC(jchoice),
+  svn_wc_conflict_result_t *result =
+         svn_wc_create_conflict_result(EnumMapper::toConflictChoice(jchoice),
                                        mergedPath.pstrdup(pool),
                                        pool);
-}
 
-svn_wc_conflict_choice_t ConflictResolverCallback::javaChoiceToC(jint jchoice)
-{
-  switch (jchoice)
-    {
-    case org_apache_subversion_javahl_ConflictResult_postpone:
-    default:
-      return svn_wc_conflict_choose_postpone;
-    case org_apache_subversion_javahl_ConflictResult_chooseBase:
-      return svn_wc_conflict_choose_base;
-    case org_apache_subversion_javahl_ConflictResult_chooseTheirsFull:
-      return svn_wc_conflict_choose_theirs_full;
-    case org_apache_subversion_javahl_ConflictResult_chooseMineFull:
-      return svn_wc_conflict_choose_mine_full;
-    case org_apache_subversion_javahl_ConflictResult_chooseTheirsConflict:
-      return svn_wc_conflict_choose_theirs_conflict;
-    case org_apache_subversion_javahl_ConflictResult_chooseMineConflict:
-      return svn_wc_conflict_choose_mine_conflict;
-    case org_apache_subversion_javahl_ConflictResult_chooseMerged:
-      return svn_wc_conflict_choose_merged;
-    }
+  env->DeleteLocalRef(jchoice);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
+  return result;
 }

Modified: subversion/trunk/subversion/bindings/javahl/native/ConflictResolverCallback.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ConflictResolverCallback.h?rev=925343&r1=925342&r2=925343&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ConflictResolverCallback.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/ConflictResolverCallback.h Fri Mar
19 17:23:40 2010
@@ -91,12 +91,6 @@ class ConflictResolverCallback
    */
   static svn_wc_conflict_result_t * javaResultToC(jobject result,
                                                   apr_pool_t *pool);
-
-  /**
-   * Convert the Java conflict resolution @a choice into the
-   * appropriate C enum value.
-   */
-  static svn_wc_conflict_choice_t javaChoiceToC(jint choice);
 };
 
 #endif  // CONFLICTRESOLVERCALLBACK_H

Modified: subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp?rev=925343&r1=925342&r2=925343&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp Fri Mar 19 17:23:40
2010
@@ -494,6 +494,33 @@ jobject EnumMapper::mapTristate(svn_tris
     }
 }
 
+svn_wc_conflict_choice_t EnumMapper::toConflictChoice(jobject jchoice)
+{
+  JNIEnv *env = JNIUtil::getEnv();
+
+  jstring jname = getName(JAVA_PACKAGE"/ConflictResult$Choice", jchoice);
+  if (JNIUtil::isJavaExceptionThrown())
+    return svn_wc_conflict_choose_postpone;
+
+  JNIStringHolder str(jname);
+  std::string name((const char *)str);
+
+  if (name == "chooseBase")
+    return svn_wc_conflict_choose_base;
+  else if (name == "chooseTheirsFull")
+    return svn_wc_conflict_choose_theirs_full;
+  else if (name == "chooseMineFull")
+    return svn_wc_conflict_choose_mine_full;
+  else if (name == "chooseTheirsConflict")
+    return svn_wc_conflict_choose_theirs_conflict;
+  else if (name == "chooseMineConflict")
+    return svn_wc_conflict_choose_mine_conflict;
+  else if (name == "chooseMerged")
+    return svn_wc_conflict_choose_merged;
+  else
+    return svn_wc_conflict_choose_postpone;
+}
+
 svn_opt_revision_kind EnumMapper::toRevisionKind(jobject jkind)
 {
   JNIEnv *env = JNIUtil::getEnv();

Modified: subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h?rev=925343&r1=925342&r2=925343&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h Fri Mar 19 17:23:40 2010
@@ -44,6 +44,7 @@ class EnumMapper
   /* Converting to C enum's */
   static svn_depth_t toDepth(jobject jdepth);
   static svn_opt_revision_kind toRevisionKind(jobject jkind);
+  static svn_wc_conflict_choice_t toConflictChoice(jobject jchoice);
 
   /* Converting from C enum's */
   static jint mapCommitMessageStateFlags(apr_byte_t flags);

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=925343&r1=925342&r2=925343&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
Fri Mar 19 17:23:40 2010
@@ -668,7 +668,7 @@ Java_org_apache_subversion_javahl_SVNCli
 
 JNIEXPORT void JNICALL
 Java_org_apache_subversion_javahl_SVNClient_resolve
-(JNIEnv *env, jobject jthis, jstring jpath, jobject jdepth, jint jchoice)
+(JNIEnv *env, jobject jthis, jstring jpath, jobject jdepth, jobject jchoice)
 {
   JNIEntry(SVNClient, resolve);
   SVNClient *cl = SVNClient::getCppObject(jthis);
@@ -682,7 +682,7 @@ Java_org_apache_subversion_javahl_SVNCli
     return;
 
   cl->resolve(path, EnumMapper::toDepth(jdepth),
-              (svn_wc_conflict_choice_t) jchoice);
+              EnumMapper::toConflictChoice(jchoice));
 }
 
 JNIEXPORT jlong JNICALL

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ConflictResult.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ConflictResult.java?rev=925343&r1=925342&r2=925343&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ConflictResult.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ConflictResult.java
Fri Mar 19 17:23:40 2010
@@ -33,50 +33,10 @@ package org.apache.subversion.javahl;
 public class ConflictResult
 {
     /**
-     * Nothing done to resolve the conflict; conflict remains.
-     */
-    public static final int postpone = 0;
-
-    /**
-     * Resolve the conflict by choosing the base file.
-     */
-    public static final int chooseBase = 1;
-
-    /**
-     * Resolve the conflict by choosing the incoming (repository)
-     * version of the object.
-     */
-    public static final int chooseTheirsFull = 2;
-
-    /**
-     * Resolve the conflict by choosing own (local) version of the
-     * object.
-     */
-    public static final int chooseMineFull = 3;
-
-    /**
-     * Resolve the conflict by choosing the incoming (repository)
-     * version of the object (for conflicted hunks only).
-     */
-    public static final int chooseTheirsConflict = 4;
-
-    /**
-     * Resolve the conflict by choosing own (local) version of the
-     * object (for conflicted hunks only).
-     */
-    public static final int chooseMineConflict = 5;
-
-    /**
-     * Resolve the conflict by choosing the merged object
-     * (potentially manually edited).
-     */
-    public static final int chooseMerged = 6;
-
-    /**
      * A value corresponding to the
      * <code>svn_wc_conflict_choice_t</code> enum.
      */
-    private int choice;
+    private Choice choice;
 
     /**
      * The path to the result of a merge, or <code>null</code>.
@@ -86,7 +46,7 @@ public class ConflictResult
     /**
      * Create a new conflict result instace.
      */
-    public ConflictResult(int choice, String mergedPath)
+    public ConflictResult(Choice choice, String mergedPath)
     {
       this.choice = choice;
       this.mergedPath = mergedPath;
@@ -96,7 +56,7 @@ public class ConflictResult
      * @return A value corresponding to the
      * <code>svn_wc_conflict_choice_t</code> enum.
      */
-    public int getChoice()
+    public Choice getChoice()
     {
         return choice;
     }
@@ -108,4 +68,43 @@ public class ConflictResult
     {
         return mergedPath;
     }
+
+    public enum Choice
+    {
+        /** Nothing done to resolve the conflict; conflict remains.  */
+        postpone,
+
+        /** Resolve the conflict by choosing the base file.  */
+        chooseBase,
+
+        /**
+         * Resolve the conflict by choosing the incoming (repository)
+         * version of the object.
+         */
+        chooseTheirsFull,
+
+        /**
+         * Resolve the conflict by choosing own (local) version of the
+         * object.
+         */
+        chooseMineFull,
+
+        /**
+         * Resolve the conflict by choosing the incoming (repository)
+         * version of the object (for conflicted hunks only).
+         */
+        chooseTheirsConflict,
+
+        /**
+         * Resolve the conflict by choosing own (local) version of the
+         * object (for conflicted hunks only).
+         */
+        chooseMineConflict,
+
+        /**
+         * Resolve the conflict by choosing the merged object
+         * (potentially manually edited).
+         */
+        chooseMerged;
+    }
 }

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=925343&r1=925342&r2=925343&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
Fri Mar 19 17:23:40 2010
@@ -369,7 +369,7 @@ public interface ISVNClient
      * @throws SubversionException If an error occurs.
      * @since 1.5
      */
-    void resolve(String path, Depth depth, int conflictResult)
+    void resolve(String path, Depth depth, ConflictResult.Choice conflictResult)
         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=925343&r1=925342&r2=925343&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
Fri Mar 19 17:23:40 2010
@@ -266,7 +266,8 @@ public class SVNClient implements ISVNCl
     /**
      * @since 1.5
      */
-    public native void resolve(String path, Depth depth, int conflictResult)
+    public native void resolve(String path, Depth depth,
+                               ConflictResult.Choice conflictResult)
         throws SubversionException;
 
     /**

Modified: subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/ConflictResult.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/ConflictResult.java?rev=925343&r1=925342&r2=925343&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/ConflictResult.java
(original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/tigris/subversion/javahl/ConflictResult.java
Fri Mar 19 17:23:40 2010
@@ -94,8 +94,9 @@ public class ConflictResult
 
     public org.apache.subversion.javahl.ConflictResult toApache()
     {
-        return new org.apache.subversion.javahl.ConflictResult(choice,
-                                                               mergedPath);
+        return new org.apache.subversion.javahl.ConflictResult(
+            org.apache.subversion.javahl.ConflictResult.Choice.values()[choice],
+            mergedPath);
     }
 
     /**

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=925343&r1=925342&r2=925343&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
Fri Mar 19 17:23:40 2010
@@ -1058,7 +1058,9 @@ public class SVNClient implements SVNCli
     {
         try
         {
-            aSVNClient.resolve(path, Depth.toADepth(depth), conflictResult);
+            aSVNClient.resolve(path, Depth.toADepth(depth),
+               org.apache.subversion.javahl.ConflictResult.Choice.values()[
+                                                            conflictResult]);
         }
         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=925343&r1=925342&r2=925343&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
Fri Mar 19 17:23:40 2010
@@ -1285,7 +1285,7 @@ public class BasicTests extends SVNTests
 
         // flag A/mu as resolved
         client.resolve(backupTest.getWCPath()+"/A/mu", Depth.empty,
-                ConflictResult.chooseMerged);
+                ConflictResult.Choice.chooseMerged);
         backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
         backupTest.getWc().removeItem("A/mu.r1");
         backupTest.getWc().removeItem("A/mu.r2");
@@ -1293,7 +1293,7 @@ public class BasicTests extends SVNTests
 
         // flag A/D/G/rho as resolved
         client.resolve(backupTest.getWCPath()+"/A/D/G/rho", Depth.empty,
-                ConflictResult.chooseMerged);
+                ConflictResult.Choice.chooseMerged);
         backupTest.getWc().setItemTextStatus("A/D/G/rho",
                                              Status.Kind.modified);
         backupTest.getWc().removeItem("A/D/G/rho.r1");
@@ -2655,7 +2655,7 @@ public class BasicTests extends SVNTests
             {
                 public ConflictResult resolve(ConflictDescriptor descrip)
                 {
-                    return new ConflictResult(ConflictResult.chooseTheirsConflict,
+                    return new ConflictResult(ConflictResult.Choice.chooseTheirsConflict,
                                               null);
                 }
             });



Mime
View raw message