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/27 00:25:54 UTC
svn commit: r1497144 - in /subversion/trunk/subversion/bindings/javahl:
native/ src/org/apache/subversion/javahl/
src/org/apache/subversion/javahl/remote/ tests/org/apache/subversion/javahl/
Author: brane
Date: Wed Jun 26 22:25:54 2013
New Revision: 1497144
URL: http://svn.apache.org/r1497144
Log:
Wrap up the JavaHL commit editor implementation.
[in subversion/bindings/javahl/src/org/apache/subversion/javahl]
* ISVNEditor.java, remote/CommitEditor.java
(ISVNEditor.rotate): Change argument to Iterable instead of List.
* remote/CommitEditor.java
(ISVNEditor.addSymlink, ISVNEditor.alterSymlink, ISVNEditor.rotate):
Add a note to the docs that these methods are not implemented.
[in subversion/bindings/javahl/native]
* CommitEditor.cpp (build_checksum): Simplify method ID init.
(build_rotation): Rotate helper; commented out.
(CommitEditor::rotate): Add implementation, commented out.
[in subversion/bindings/javahl/tests/org/apache/subversion/javahl]
* SVNRemoteTests.java
(SVNRemoteTests.testEditorRotate): Rotate testcase, commented out.
(SVNRemoteTests.testEditorNotImplemented): Check unimplemented editor ops.
Modified:
subversion/trunk/subversion/bindings/javahl/native/CommitEditor.cpp
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/CommitEditor.java
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=1497144&r1=1497143&r2=1497144&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CommitEditor.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CommitEditor.cpp Wed Jun 26 22:25:54 2013
@@ -194,18 +194,15 @@ build_checksum(jobject jchecksum, SVN::P
static jmethodID digest_mid = 0;
static jmethodID kind_mid = 0;
- jclass cls = env->FindClass(JAVA_PACKAGE"/types/Checksum");
- if (JNIUtil::isJavaExceptionThrown())
- return checksum;
-
- if (0 == digest_mid)
+ if (0 == digest_mid || 0 == kind_mid)
{
+ jclass cls = env->FindClass(JAVA_PACKAGE"/types/Checksum");
+ if (JNIUtil::isJavaExceptionThrown())
+ return checksum;
+
digest_mid = env->GetMethodID(cls, "getDigest", "()[B");
if (JNIUtil::isJavaExceptionThrown())
return checksum;
- }
- if (0 == kind_mid)
- {
kind_mid = env->GetMethodID(cls, "getKind", "()L"
JAVA_PACKAGE"/types/Checksum$Kind;");
if (JNIUtil::isJavaExceptionThrown())
@@ -230,6 +227,57 @@ build_checksum(jobject jchecksum, SVN::P
return checksum;
}
+
+// void
+// build_rotation(const apr_array_header_t **p_relpaths,
+// const apr_array_header_t **p_revisions,
+// const Iterator& iter, SVN::Pool& pool)
+// {
+// *p_relpaths = *p_revisions = NULL;
+//
+// static jfieldID relpath_fid = 0;
+// static jfieldID revision_fid = 0;
+//
+// JNIEnv *env = JNIUtil::getEnv();
+// if (0 == relpath_fid || 0 == revision_fid)
+// {
+// jclass cls = env->FindClass(JAVA_PACKAGE"/ISVNEditor$RotatePair");
+// if (JNIUtil::isJavaExceptionThrown())
+// return;
+//
+// relpath_fid = env->GetFieldID(cls, "relativePath", "Ljava/lang/String;");
+// if (JNIUtil::isJavaExceptionThrown())
+// return;
+// revision_fid = env->GetFieldID(cls, "revision", "J");
+// if (JNIUtil::isJavaExceptionThrown())
+// return;
+// }
+//
+// apr_pool_t* result_pool = pool.getPool();
+// apr_array_header_t* relpaths = apr_array_make(
+// result_pool, 0, sizeof(const char*));
+// apr_array_header_t* revisions = apr_array_make(
+// result_pool, 0, sizeof(svn_revnum_t));
+// while (iter.hasNext())
+// {
+// jobject jpair = iter.next();
+// jobject jrelpath = env->GetObjectField(jpair, relpath_fid);
+// if (JNIUtil::isJavaExceptionThrown())
+// return;
+// jlong jrevision = env->GetLongField(jpair, revision_fid);
+// if (JNIUtil::isJavaExceptionThrown())
+// return;
+// JNIStringHolder relpath((jstring)jrelpath);
+// if (JNIUtil::isJavaExceptionThrown())
+// return;
+//
+// APR_ARRAY_PUSH(relpaths, const char*) = relpath.pstrdup(result_pool);
+// APR_ARRAY_PUSH(revisions, svn_revnum_t) = svn_revnum_t(jrevision);
+// }
+//
+// *p_relpaths = relpaths;
+// *p_revisions = revisions;
+// }
} // anonymous namespace
@@ -440,6 +488,21 @@ void CommitEditor::move(jstring jsrc_rel
void CommitEditor::rotate(jobject jelements)
{
+// if (!m_valid)
+// {
+// throw_editor_inactive();
+// return;
+// }
+// SVN_JNI_ERR(m_session->m_context->checkCancel(m_session->m_context),);
+//
+// SVN::Pool subPool(pool);
+// const apr_array_header_t* relpaths;
+// const apr_array_header_t* revisions;
+// build_rotation(&relpaths, &revisions, jelements, subPool);
+// if (JNIUtil::isJavaExceptionThrown())
+// return;
+//
+// SVN_JNI_ERR(svn_editor_rotate(m_editor, relpaths, revisions),);
throw_not_implemented("rotate");
}
Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java?rev=1497144&r1=1497143&r2=1497144&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNEditor.java Wed Jun 26 22:25:54 2013
@@ -27,7 +27,6 @@ import org.apache.subversion.javahl.type
import org.apache.subversion.javahl.callback.*;
import java.io.InputStream;
-import java.util.List;
import java.util.Map;
/**
@@ -296,7 +295,7 @@ public interface ISVNEditor
*
* @throws ClientException
*/
- void rotate(List<RotatePair> elements) throws ClientException;
+ void rotate(Iterable<RotatePair> elements) throws ClientException;
public static final class RotatePair
{
Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/CommitEditor.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/CommitEditor.java?rev=1497144&r1=1497143&r2=1497144&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/CommitEditor.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/CommitEditor.java Wed Jun 26 22:25:54 2013
@@ -31,7 +31,6 @@ import org.apache.subversion.javahl.JNIO
import org.apache.subversion.javahl.ClientException;
import java.io.InputStream;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -60,6 +59,9 @@ public class CommitEditor extends JNIObj
long replacesRevision)
throws ClientException;
+ /**
+ * <b>Note:</b> Not implemented.
+ */
public native void addSymlink(String relativePath,
String target,
Map<String, byte[]> properties,
@@ -84,6 +86,9 @@ public class CommitEditor extends JNIObj
Map<String, byte[]> properties)
throws ClientException;
+ /**
+ * <b>Note:</b> Not implemented.
+ */
public native void alterSymlink(String relativePath,
long revision,
String target,
@@ -106,7 +111,10 @@ public class CommitEditor extends JNIObj
long replacesRevision)
throws ClientException;
- public native void rotate(List<RotatePair> elements)
+ /**
+ * <b>Note:</b> Not implemented.
+ */
+ public native void rotate(Iterable<RotatePair> elements)
throws ClientException;
public native void complete() throws ClientException;
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=1497144&r1=1497143&r2=1497144&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 22:25:54 2013
@@ -598,4 +598,88 @@ public class SVNRemoteTests extends SVNT
Revision.HEAD);
assertTrue(Arrays.equals(eolstyle, propval));
}
+
+ // public void testEditorRotate() throws Exception
+ // {
+ // ISVNRemote session = getSession();
+ //
+ // ArrayList<ISVNEditor.RotatePair> rotation =
+ // new ArrayList<ISVNEditor.RotatePair>(3);
+ // rotation.add(new ISVNEditor.RotatePair("A/B", 1));
+ // rotation.add(new ISVNEditor.RotatePair("A/C", 1));
+ // rotation.add(new ISVNEditor.RotatePair("A/D", 1));
+ //
+ // CommitContext cc =
+ // new CommitContext(session, "Rotate A/B -> A/C -> A/D");
+ // try {
+ // // No alter-dir of A is needed, children remain the same.
+ // cc.editor.rotate(rotation);
+ // cc.editor.complete();
+ // } finally {
+ // cc.editor.dispose();
+ // }
+ //
+ // assertEquals(2, cc.getRevision());
+ // assertEquals(2, session.getLatestRevision());
+ //
+ // HashMap<String, DirEntry> dirents = new HashMap<String, DirEntry>();
+ // HashMap<String, byte[]> properties = new HashMap<String, byte[]>();
+ //
+ // // A/B is now what used to be A/D, so A/B/H must exist
+ // session.getDirectory(Revision.SVN_INVALID_REVNUM, "A/B",
+ // DirEntry.Fields.all, dirents, properties);
+ // assertEquals(dirents.get("H").getPath(), "H");
+ //
+ // // A/C is now what used to be A/B, so A/C/F must exist
+ // session.getDirectory(Revision.SVN_INVALID_REVNUM, "A/C",
+ // DirEntry.Fields.all, dirents, properties);
+ // assertEquals(dirents.get("F").getPath(), "F");
+ //
+ // // A/D is now what used to be A/C and must be empty
+ // session.getDirectory(Revision.SVN_INVALID_REVNUM, "A/D",
+ // DirEntry.Fields.all, dirents, properties);
+ // assertTrue(dirents.isEmpty());
+ // }
+
+ // Sanity check so that we don't forget about unimplemented methods.
+ public void testEditorNotImplemented() throws Exception
+ {
+ ISVNRemote session = getSession();
+
+ HashMap<String, byte[]> props = new HashMap<String, byte[]>();
+ ArrayList<ISVNEditor.RotatePair> rotation =
+ new ArrayList<ISVNEditor.RotatePair>();
+
+ CommitContext cc = new CommitContext(session, "not implemented");
+ try {
+ String exmsg;
+
+ try {
+ exmsg = "";
+ cc.editor.addSymlink("", "", props, 1);
+ } catch (IllegalStateException ex) {
+ exmsg = ex.getMessage();
+ }
+ assertEquals("Not implemented: CommitEditor.addSymlink", exmsg);
+
+ try {
+ exmsg = "";
+ cc.editor.alterSymlink("", 1, "", null);
+ } catch (IllegalStateException ex) {
+ exmsg = ex.getMessage();
+ }
+ assertEquals("Not implemented: CommitEditor.alterSymlink", exmsg);
+
+ try {
+ exmsg = "";
+ cc.editor.rotate(rotation);
+ } catch (IllegalStateException ex) {
+ exmsg = ex.getMessage();
+ }
+ assertEquals("Not implemented: CommitEditor.rotate", exmsg);
+ } finally {
+ cc.editor.dispose();
+ }
+
+ }
}