You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2012/10/18 02:01:03 UTC
svn commit: r1399486 - in /subversion/trunk/subversion/bindings/javahl:
native/ src/org/apache/subversion/javahl/
src/org/apache/subversion/javahl/callback/
Author: hwright
Date: Thu Oct 18 00:01:03 2012
New Revision: 1399486
URL: http://svn.apache.org/viewvc?rev=1399486&view=rev
Log:
JavaHL: Update bindings to the most recent import API. This adds a filter
function callback to the Java side, and punches it through to the C layer.
This builds, but has not been fully tested.
[ in subversion/bindings/javahl/ ]
* native/ImportFilterCallback.cpp,
native/ImportFilterCallback.h: New.
* native/SVNClient.h,
native/SVNClient.cpp
(doImport): Add ImportFilterCallback argument, and update API.
* native/org_apache_subversion_javahl_SVNClient.cpp
(Java_org_apache_subversion_javahl_SVNClient_doImport): Add the import filter
callback and pass it down the bindings stack.
* src/org/apache/subversion/javahl/ISVNClient.java,
src/org/apache/subversion/javahl/SVNClient.java
(doImport): New version of the import API.
* src/org/apache/subversion/javahl/callback/ImportFilterCallback.java: New.
Added:
subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.cpp (with props)
subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.h (with props)
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ImportFilterCallback.java (with props)
Modified:
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
Added: subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.cpp?rev=1399486&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.cpp (added)
+++ subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.cpp Thu Oct 18 00:01:03 2012
@@ -0,0 +1,118 @@
+/**
+ * @copyright
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ * @endcopyright
+ *
+ * @file ImportFilterCallback.cpp
+ * @brief Implementation of the class ImportFilterCallback
+ */
+
+#include "ImportFilterCallback.h"
+#include "EnumMapper.h"
+#include "CreateJ.h"
+#include "JNIUtil.h"
+#include "svn_time.h"
+
+/**
+ * Create a ImportFilterCallback object
+ * @param jcallback the Java callback object.
+ */
+ImportFilterCallback::ImportFilterCallback(jobject jcallback)
+{
+ m_callback = jcallback;
+}
+
+/**
+ * Destroy a ImportFilterCallback object
+ */
+ImportFilterCallback::~ImportFilterCallback()
+{
+ // The m_callback does not need to be destroyed, because it is the passed
+ // in parameter to the Java SVNClient.list method.
+}
+
+svn_error_t *
+ImportFilterCallback::callback(void *baton,
+ svn_boolean_t *filtered,
+ const char *local_abspath,
+ const svn_io_dirent2_t *dirent,
+ apr_pool_t *pool)
+{
+ if (baton)
+ return ((ImportFilterCallback *)baton)->doImportFilter(filtered,
+ local_abspath, dirent, pool);
+
+ return SVN_NO_ERROR;
+}
+
+/**
+ * Callback called for each directory entry.
+ */
+svn_error_t *
+ImportFilterCallback::doImportFilter(svn_boolean_t *filtered,
+ const char *local_abspath,
+ const svn_io_dirent2_t *dirent,
+ apr_pool_t *pool)
+{
+ JNIEnv *env = JNIUtil::getEnv();
+
+ // Create a local frame for our references
+ env->PushLocalFrame(LOCAL_FRAME_SIZE);
+ if (JNIUtil::isJavaExceptionThrown())
+ return SVN_NO_ERROR;
+
+ // The method id will not change during the time this library is
+ // loaded, so it can be cached.
+ static jmethodID mid = 0;
+ if (mid == 0)
+ {
+ jclass clazz = env->FindClass(JAVA_PACKAGE"/callback/ImportFilterCallback");
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(SVN_NO_ERROR);
+
+ mid = env->GetMethodID(clazz, "filter",
+ "(Ljava/lang/String;"
+ "L"JAVA_PACKAGE"/types/NodeKind;Z)Z");
+ if (JNIUtil::isJavaExceptionThrown() || mid == 0)
+ POP_AND_RETURN(SVN_NO_ERROR);
+ }
+
+ // convert the parameters to their Java relatives
+ jstring jpath = JNIUtil::makeJString(local_abspath);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(SVN_NO_ERROR);
+
+ jboolean jspecial = (dirent->special ? JNI_TRUE : JNI_FALSE);
+
+ jobject jkind = EnumMapper::mapNodeKind(dirent->kind);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(SVN_NO_ERROR);
+
+ // call the Java method
+ jboolean jfilter = env->CallBooleanMethod(m_callback, mid, jpath, jkind,
+ jspecial);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(SVN_NO_ERROR);
+
+ *filtered = jfilter ? TRUE : FALSE;
+
+ env->PopLocalFrame(NULL);
+ return SVN_NO_ERROR;
+}
Propchange: subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.h?rev=1399486&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.h (added)
+++ subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.h Thu Oct 18 00:01:03 2012
@@ -0,0 +1,62 @@
+/**
+ * @copyright
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ * @endcopyright
+ *
+ * @file ImportFilterCallback.h
+ * @brief Interface of the class ImportFilterCallback
+ */
+
+#ifndef IMPORT_FILTER_CALLBACK_H
+#define IMPORT_FILTER_CALLBACK_H
+
+#include <jni.h>
+#include "svn_client.h"
+
+/**
+ * This class holds a Java callback object, which will receive every
+ * directory entry for which the callback information is requested.
+ */
+class ImportFilterCallback
+{
+public:
+ ImportFilterCallback(jobject jcallback);
+ ~ImportFilterCallback();
+
+ static svn_error_t *callback(void *baton,
+ svn_boolean_t *filtered,
+ const char *local_abspath,
+ const svn_io_dirent2_t *dirent,
+ apr_pool_t *scratch_pool);
+
+protected:
+ svn_error_t *doImportFilter(svn_boolean_t *filtered,
+ const char *local_abspath,
+ const svn_io_dirent2_t *dirent,
+ apr_pool_t *pool);
+
+private:
+ /**
+ * This a local reference to the Java object.
+ */
+ jobject m_callback;
+};
+
+#endif // IMPORT_FILTER_CALLBACK_H
Propchange: subversion/trunk/subversion/bindings/javahl/native/ImportFilterCallback.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp?rev=1399486&r1=1399485&r2=1399486&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp Thu Oct 18 00:01:03 2012
@@ -44,6 +44,7 @@
#include "StatusCallback.h"
#include "ChangelistCallback.h"
#include "ListCallback.h"
+#include "ImportFilterCallback.h"
#include "JNIByteArray.h"
#include "CommitMessage.h"
#include "EnumMapper.h"
@@ -553,7 +554,9 @@ jlong SVNClient::doSwitch(const char *pa
void SVNClient::doImport(const char *path, const char *url,
CommitMessage *message, svn_depth_t depth,
bool noIgnore, bool ignoreUnknownNodeTypes,
- RevpropTable &revprops, CommitCallback *callback)
+ RevpropTable &revprops,
+ ImportFilterCallback *ifCallback,
+ CommitCallback *commitCallback)
{
SVN::Pool subPool(pool);
SVN_JNI_NULL_PTR_EX(path, "path", );
@@ -567,10 +570,11 @@ void SVNClient::doImport(const char *pat
if (ctx == NULL)
return;
- SVN_JNI_ERR(svn_client_import4(intPath.c_str(), intUrl.c_str(), depth,
+ SVN_JNI_ERR(svn_client_import5(intPath.c_str(), intUrl.c_str(), depth,
noIgnore, ignoreUnknownNodeTypes,
revprops.hash(subPool),
- CommitCallback::callback, callback,
+ ImportFilterCallback::callback, ifCallback,
+ CommitCallback::callback, commitCallback,
ctx, subPool.getPool()), );
}
Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.h?rev=1399486&r1=1399485&r2=1399486&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.h Thu Oct 18 00:01:03 2012
@@ -46,6 +46,7 @@ class LogMessageCallback;
class InfoCallback;
class CommitCallback;
class ListCallback;
+class ImportFilterCallback;
class StatusCallback;
class OutputStream;
class PatchCallback;
@@ -107,7 +108,8 @@ class SVNClient :public SVNBase
const char *localPath, bool dryRun);
void doImport(const char *path, const char *url, CommitMessage *message,
svn_depth_t depth, bool noIgnore, bool ignoreUnknownNodeTypes,
- RevpropTable &revprops, CommitCallback *callback);
+ RevpropTable &revprops, ImportFilterCallback *ifCallback,
+ CommitCallback *commitCallback);
jlong doSwitch(const char *path, const char *url, Revision &revision,
Revision &pegRevision, svn_depth_t depth,
bool depthIsSticky, bool ignoreExternals,
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=1399486&r1=1399485&r2=1399486&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 Thu Oct 18 00:01:03 2012
@@ -47,6 +47,7 @@
#include "InfoCallback.h"
#include "StatusCallback.h"
#include "ListCallback.h"
+#include "ImportFilterCallback.h"
#include "ChangelistCallback.h"
#include "StringArray.h"
#include "RevpropTable.h"
@@ -712,7 +713,7 @@ JNIEXPORT void JNICALL
Java_org_apache_subversion_javahl_SVNClient_doImport
(JNIEnv *env, jobject jthis, jstring jpath, jstring jurl, jobject jdepth,
jboolean jnoIgnore, jboolean jignoreUnknownNodeTypes, jobject jrevpropTable,
- jobject jmessage, jobject jcallback)
+ jobject jimportFilterCallback, jobject jmessage, jobject jcommitCallback)
{
JNIEntry(SVNClient, doImport);
SVNClient *cl = SVNClient::getCppObject(jthis);
@@ -737,11 +738,14 @@ Java_org_apache_subversion_javahl_SVNCli
if (JNIUtil::isExceptionThrown())
return;
- CommitCallback callback(jcallback);
+ ImportFilterCallback importFilterCallback(jimportFilterCallback);
+ CommitCallback commitCallback(jcommitCallback);
+
cl->doImport(path, url, &message, EnumMapper::toDepth(jdepth),
jnoIgnore ? true : false,
jignoreUnknownNodeTypes ? true : false, revprops,
- jcallback ? &callback : NULL);
+ jimportFilterCallback ? &importFilterCallback : NULL,
+ jcommitCallback ? &commitCallback : NULL);
}
JNIEXPORT jobject JNICALL
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=1399486&r1=1399485&r2=1399486&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 Thu Oct 18 00:01:03 2012
@@ -406,6 +406,13 @@ public interface ISVNClient
void doImport(String path, String url, Depth depth,
boolean noIgnore, boolean ignoreUnknownNodeTypes,
Map<String, String> revpropTable,
+ ImportFilterCallback importFilterCallback,
+ CommitMessageCallback handler, CommitCallback commitCallback)
+ throws ClientException;
+
+ void doImport(String path, String url, Depth depth,
+ boolean noIgnore, boolean ignoreUnknownNodeTypes,
+ Map<String, String> revpropTable,
CommitMessageCallback handler, CommitCallback callback)
throws ClientException;
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=1399486&r1=1399485&r2=1399486&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 Thu Oct 18 00:01:03 2012
@@ -230,9 +230,22 @@ public class SVNClient implements ISVNCl
boolean noIgnore,
boolean ignoreUnknownNodeTypes,
Map<String, String> revpropTable,
- CommitMessageCallback handler, CommitCallback callback)
+ ImportFilterCallback importFilterCallback,
+ CommitMessageCallback handler,
+ CommitCallback commitCallback)
throws ClientException;
+ public void doImport(String path, String url, Depth depth, boolean noIgnore,
+ boolean ignoreUnknownNodeTypes,
+ Map<String, String> revpropTable,
+ CommitMessageCallback handler,
+ CommitCallback callback)
+ throws ClientException
+ {
+ doImport(path, url, depth, noIgnore, ignoreUnknownNodeTypes,
+ revpropTable, null, handler, callback);
+ }
+
public native Set<String> suggestMergeSources(String path,
Revision pegRevision)
throws SubversionException;
Added: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ImportFilterCallback.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ImportFilterCallback.java?rev=1399486&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ImportFilterCallback.java (added)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ImportFilterCallback.java Thu Oct 18 00:01:03 2012
@@ -0,0 +1,40 @@
+/**
+ * @copyright
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ * @endcopyright
+ */
+
+package org.apache.subversion.javahl.callback;
+
+import org.apache.subversion.javahl.ISVNClient;
+import org.apache.subversion.javahl.types.NodeKind;
+
+/**
+ * This interface is used to filter imported nodes in the
+ * {@link ISVNClient#import} call.
+ */
+public interface ImportFilterCallback
+{
+ /**
+ * This method will be called for each node. Returns true to filter the
+ * node (and its descendants) from the import.
+ */
+ public boolean filter(String path, NodeKind kind, boolean special);
+}
Propchange: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ImportFilterCallback.java
------------------------------------------------------------------------------
svn:eol-style = native