You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/06/26 08:33:53 UTC

svn commit: r1496782 - in /subversion/trunk/subversion/bindings/javahl: native/CommitEditor.cpp native/EnumMapper.cpp native/EnumMapper.h tests/org/apache/subversion/javahl/SVNRemoteTests.java

Author: brane
Date: Wed Jun 26 06:33:53 2013
New Revision: 1496782

URL: http://svn.apache.org/r1496782
Log:
Implement EV2 add_absent and delete ops in JavaHL RA commit editor.

[in subversion/bindings/javahl/native]
* EnumMapper.h, EnumMapper.cpp (EnumMapper::toNodeKind): New;
   converts NodeKind enum to svn_node_kind_t.
* CommitEditor.cpp (CommitEditor::addAbsent, CommitEditor::remove): Implement.
  (CommitEditor::addSymlink, CommitEditor::alterSymlink):
   Mark "permanently" not implemented (i.e., until the EV2 impl has them).

[in subversion/bindings/javahl/tests/org/apache/subversion/javahl]
* SVNRemoteTests.java (SVNRemoteTests.CommitContext): New helper class.
  (SVNRemoteTests.testEditorCopy, SVNRemoteTests.testEditorDelete): New tests.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/CommitEditor.cpp
    subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp
    subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java

Modified: subversion/trunk/subversion/bindings/javahl/native/CommitEditor.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CommitEditor.cpp?rev=1496782&r1=1496781&r2=1496782&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CommitEditor.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CommitEditor.cpp Wed Jun 26 06:33:53 2013
@@ -24,6 +24,7 @@
  * @brief Implementation of the class CommitEditor
  */
 
+#include "EnumMapper.h"
 #include "CommitEditor.h"
 #include "LockTokenTable.h"
 #include "RevpropTable.h"
@@ -193,12 +194,6 @@ void CommitEditor::addSymlink(jstring jr
                               jstring jtarget, jobject jproperties,
                               jlong jreplaces_revision)
 {
-  if (!m_valid)
-    {
-      throw_editor_inactive();
-      return;
-    }
-  SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);
   throw_not_implemented("addSymlink");
 }
 
@@ -211,7 +206,13 @@ void CommitEditor::addAbsent(jstring jre
       return;
     }
   SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);
-  throw_not_implemented("addAbsent");
+
+  JNIStringHolder relpath(jrelpath);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+  SVN_JNI_ERR(svn_editor_add_absent(m_editor,
+                                    relpath, EnumMapper::toNodeKind(jkind),
+                                    svn_revnum_t(jreplaces_revision)),);
 }
 
 void CommitEditor::alterDirectory(jstring jrelpath, jlong jrevision,
@@ -242,12 +243,6 @@ void CommitEditor::alterFile(jstring jre
 void CommitEditor::alterSymlink(jstring jrelpath, jlong jrevision,
                                 jstring jtarget, jobject jproperties)
 {
-  if (!m_valid)
-    {
-      throw_editor_inactive();
-      return;
-    }
-  SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);
   throw_not_implemented("alterSymlink");
 }
 
@@ -259,7 +254,11 @@ void CommitEditor::remove(jstring jrelpa
       return;
     }
   SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);
-  throw_not_implemented("delete");
+
+  JNIStringHolder relpath(jrelpath);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+  SVN_JNI_ERR(svn_editor_delete(m_editor, relpath, svn_revnum_t(jrevision)),);
 }
 
 void CommitEditor::copy(jstring jsrc_relpath, jlong jsrc_revision,

Modified: subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp?rev=1496782&r1=1496781&r2=1496782&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/EnumMapper.cpp Wed Jun 26 06:33:53 2013
@@ -191,6 +191,12 @@ int EnumMapper::toLogLevel(jobject jLogL
   return getOrdinal(JAVA_PACKAGE"/SVNClient$ClientLogLevel", jLogLevel);
 }
 
+svn_node_kind_t EnumMapper::toNodeKind(jobject jNodeKind)
+{
+  return svn_node_kind_t(
+      getOrdinal(JAVA_PACKAGE"/types/NodeKind", jNodeKind));
+}
+
 svn_depth_t EnumMapper::toDepth(jobject jdepth)
 {
   // The offset for depths is -2

Modified: subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h?rev=1496782&r1=1496781&r2=1496782&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/EnumMapper.h Wed Jun 26 06:33:53 2013
@@ -48,6 +48,7 @@ class EnumMapper
   static svn_wc_conflict_choice_t toConflictChoice(jobject jchoice);
   static int toMergeinfoLogKind(jobject jLogKind);
   static int toLogLevel(jobject jLogLevel);
+  static svn_node_kind_t toNodeKind(jobject jNodeKind);
 
   /* Converting from C enum's */
   static jint mapCommitMessageStateFlags(apr_byte_t flags);

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java?rev=1496782&r1=1496781&r2=1496782&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java (original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java Wed Jun 26 06:33:53 2013
@@ -370,46 +370,79 @@ public class SVNRemoteTests extends SVNT
             assertTrue(e.getKey().startsWith("svn:entry:"));
     }
 
-    private class MyCommitCallback implements CommitCallback
+    private final class CommitContext implements CommitCallback
     {
-        private CommitInfo info = null;
-
-        public void commitInfo(CommitInfo info) {
-            this.info = info;
+        public final ISVNEditor editor;
+        public CommitContext(ISVNRemote session, String logstr)
+            throws ClientException
+        {
+            Charset UTF8 = Charset.forName("UTF-8");
+            byte[] log = (logstr == null
+                          ? new byte[0]
+                          : logstr.getBytes(UTF8));
+            HashMap<String, byte[]> revprops = new HashMap<String, byte[]>();
+            revprops.put("svn:log", log);
+            editor = session.getCommitEditor(revprops, this, null, false);
         }
 
-        public long getRevision() {
-            if (info != null)
-                return info.getRevision();
-            else
-                return Revision.SVN_INVALID_REVNUM;
-        }
+        public void commitInfo(CommitInfo info) { this.info = info; }
+        public long getRevision() { return info.getRevision(); }
+
+        private CommitInfo info;
     }
 
-    public void testRemoteCopy() throws Exception
+    public void testEditorCopy() throws Exception
     {
         ISVNRemote session = getSession();
-
-        HashMap<String, byte[]> revprops = new HashMap<String, byte[]>();
-        revprops.put("svn:log", new byte[0]);
-
-        MyCommitCallback commitcb = new MyCommitCallback();
-
-        ISVNEditor editor =
-            session.getCommitEditor(revprops, commitcb, null, false);
+        CommitContext cc =
+            new CommitContext(session, "Copy A/B/lambda -> A/B/omega");
 
         try {
-            editor.copy("A/B/lambda", 1, "A/B/omega",
-                        Revision.SVN_INVALID_REVNUM);
-            editor.complete();
+            cc.editor.copy("A/B/lambda", 1, "A/B/omega",
+                           Revision.SVN_INVALID_REVNUM);
+            cc.editor.complete();
         } finally {
-            editor.dispose();
+            cc.editor.dispose();
         }
 
-        assertEquals(2, commitcb.getRevision());
+        assertEquals(2, cc.getRevision());
         assertEquals(2, session.getLatestRevision());
         assertEquals(NodeKind.file,
                      session.checkPath("A/B/omega",
                                        Revision.SVN_INVALID_REVNUM));
     }
+
+    public void testEditorDelete() throws Exception
+    {
+        ISVNRemote session = getSession();
+        CommitContext cc =
+            new CommitContext(session, "Delete all greek files");
+
+        String[] filePaths = { "iota",
+                               "A/mu",
+                               "A/B/lambda",
+                               "A/B/E/alpha",
+                               "A/B/E/beta",
+                               "A/D/gamma",
+                               "A/D/G/pi",
+                               "A/D/G/rho",
+                               "A/D/G/tau",
+                               "A/D/H/chi",
+                               "A/D/H/omega",
+                               "A/D/H/psi" };
+
+        try {
+            for (String path : filePaths)
+                cc.editor.delete(path, 1);
+            cc.editor.complete();
+        } finally {
+            cc.editor.dispose();
+        }
+
+        assertEquals(2, cc.getRevision());
+        assertEquals(2, session.getLatestRevision());
+        for (String path : filePaths)
+            assertEquals(NodeKind.none,
+                         session.checkPath(path, Revision.SVN_INVALID_REVNUM));
+    }
 }