subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1785430 - in /subversion/trunk/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/ src/org/apache/subversion/javahl/callback/
Date Sat, 04 Mar 2017 06:16:58 GMT
Author: brane
Date: Sat Mar  4 06:16:58 2017
New Revision: 1785430

URL: http://svn.apache.org/viewvc?rev=1785430&view=rev
Log:
Expose svn_client_list4() in JavaHL.

[in subversion/bindings/javahl]
* src/org/apache/subversion/javahl/ISVNClient.java
  (ISVNClient.list): Add new overload and deprecate the old variant.
* src/org/apache/subversion/javahl/SVNClient.java
  (SVNClient.list): Update the native method signature and reimplement
   the old overloaded variant as a wrapper for the new native method.
* src/org/apache/subversion/javahl/callback/ListItemCallback.java:
   New callback interface for ISVNClient.list.

* native/org_apache_subversion_javahl_SVNClient.cpp
  (Java_org_apache_subversion_javahl_SVNClient_list): Update native method.

* native/SVNClient.h (SVNClient::list): Update method prototype.
* native/SVNClient.cpp (SVNClient::list): Update implementation.
* native/ListCallback.h (ListCallback::doList): Update prototype.
* native/ListCallback.cpp
  (ListCallback::doList): Update implementation.
  (ListCallback::callback): Pass externals info to doList.

Added:
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ListItemCallback.java
  (with props)
Modified:
    subversion/trunk/subversion/bindings/javahl/native/ListCallback.cpp
    subversion/trunk/subversion/bindings/javahl/native/ListCallback.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

Modified: subversion/trunk/subversion/bindings/javahl/native/ListCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ListCallback.cpp?rev=1785430&r1=1785429&r2=1785430&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ListCallback.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/ListCallback.cpp Sat Mar  4 06:16:58
2017
@@ -54,13 +54,15 @@ ListCallback::callback(void *baton,
                        const svn_dirent_t *dirent,
                        const svn_lock_t *lock,
                        const char *abs_path,
-                       const char * /* external_parent_url */,
-                       const char * /* external_target */,
+                       const char *external_parent_url,
+                       const char *external_target,
                        apr_pool_t *scratch_pool)
 {
   if (baton)
     return static_cast<ListCallback *>(baton)->doList(
-            path, dirent, lock, abs_path, scratch_pool);
+            path, dirent, lock, abs_path,
+            external_parent_url, external_target,
+            scratch_pool);
 
   return SVN_NO_ERROR;
 }
@@ -73,6 +75,8 @@ ListCallback::doList(const char *path,
                      const svn_dirent_t *dirent,
                      const svn_lock_t *lock,
                      const char *abs_path,
+                     const char *external_parent_url,
+                     const char *external_target,
                      apr_pool_t *pool)
 {
   JNIEnv *env = JNIUtil::getEnv();
@@ -87,13 +91,17 @@ ListCallback::doList(const char *path,
   static jmethodID mid = 0;
   if (mid == 0)
     {
-      jclass clazz = env->FindClass(JAVAHL_CLASS("/callback/ListCallback"));
+      jclass clazz = env->FindClass(JAVAHL_CLASS("/callback/ListItemCallback"));
       if (JNIUtil::isJavaExceptionThrown())
         POP_AND_RETURN(SVN_NO_ERROR);
 
       mid = env->GetMethodID(clazz, "doEntry",
-                             "(" JAVAHL_ARG("/types/DirEntry;")
-                             JAVAHL_ARG("/types/Lock;") ")V");
+                             "("
+                             JAVAHL_ARG("/types/DirEntry;")
+                             JAVAHL_ARG("/types/Lock;")
+                             "Ljava/lang/String;"
+                             "Ljava/lang/String;"
+                             ")V");
       if (JNIUtil::isJavaExceptionThrown() || mid == 0)
         POP_AND_RETURN(SVN_NO_ERROR);
     }
@@ -111,8 +119,16 @@ ListCallback::doList(const char *path,
         POP_AND_RETURN(SVN_NO_ERROR);
     }
 
+  jstring jexternalParentURL = JNIUtil::makeJString(external_parent_url);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN(SVN_NO_ERROR);
+
+  jstring jexternalTarget = JNIUtil::makeJString(external_target);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN(SVN_NO_ERROR);
+
   // call the Java method
-  env->CallVoidMethod(m_callback, mid, jdirentry, jlock);
+  env->CallVoidMethod(m_callback, mid, jdirentry, jlock, jexternalParentURL, jexternalTarget);
 
   POP_AND_RETURN_EXCEPTION_AS_SVNERROR();
 }

Modified: subversion/trunk/subversion/bindings/javahl/native/ListCallback.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ListCallback.h?rev=1785430&r1=1785429&r2=1785430&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ListCallback.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/ListCallback.h Sat Mar  4 06:16:58
2017
@@ -54,6 +54,8 @@ protected:
                       const svn_dirent_t *dirent,
                       const svn_lock_t *lock,
                       const char *abs_path,
+                      const char *external_parent_url,
+                      const char *external_target,
                       apr_pool_t *pool);
 
 private:

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp?rev=1785430&r1=1785429&r2=1785430&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp Sat Mar  4 06:16:58 2017
@@ -167,8 +167,9 @@ const char *SVNClient::getLastPath()
  * List directory entries of a URL.
  */
 void SVNClient::list(const char *url, Revision &revision,
-                     Revision &pegRevision, svn_depth_t depth,
-                     int direntFields, bool fetchLocks,
+                     Revision &pegRevision, StringArray &patterns,
+                     svn_depth_t depth, int direntFields,
+                     bool fetchLocks, bool includeExternals,
                      ListCallback *callback)
 {
     SVN::Pool subPool(pool);
@@ -181,13 +182,14 @@ void SVNClient::list(const char *url, Re
     Path urlPath(url, subPool);
     SVN_JNI_ERR(urlPath.error_occurred(), );
 
-    SVN_JNI_ERR(svn_client_list3(urlPath.c_str(),
+    SVN_JNI_ERR(svn_client_list4(urlPath.c_str(),
                                  pegRevision.revision(),
                                  revision.revision(),
+                                 patterns.array(subPool),
                                  depth,
                                  direntFields,
                                  fetchLocks,
-                                 FALSE, // include_externals
+                                 includeExternals,
                                  ListCallback::callback,
                                  callback,
                                  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=1785430&r1=1785429&r2=1785430&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.h Sat Mar  4 06:16:58 2017
@@ -189,7 +189,8 @@ class SVNClient :public SVNBase
               bool depthAsSticky, StringArray &changelists,
               StatusCallback *callback);
   void list(const char *url, Revision &revision, Revision &pegRevision,
-            svn_depth_t depth, int direntFields, bool fetchLocks,
+            StringArray &patterns, svn_depth_t depth, int direntFields,
+            bool fetchLocks, bool includeExternals,
             ListCallback *callback);
   jbyteArray revProperty(const char *path, const char *name, Revision &rev);
   void setRevProperty(const char *path, const char *name,

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=1785430&r1=1785429&r2=1785430&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
Sat Mar  4 06:16:58 2017
@@ -156,8 +156,8 @@ Java_org_apache_subversion_javahl_SVNCli
 JNIEXPORT void JNICALL
 Java_org_apache_subversion_javahl_SVNClient_list
 (JNIEnv *env, jobject jthis, jstring jurl, jobject jrevision,
- jobject jpegRevision, jobject jdepth, jint jdirentFields,
- jboolean jfetchLocks, jobject jcallback)
+ jobject jpegRevision, jobject jpatterns, jobject jdepth, jint jdirentFields,
+ jboolean jfetchLocks, jboolean jincludeExternals, jobject jcallback)
 {
   JNIEntry(SVNClient, list);
   SVNClient *cl = SVNClient::getCppObject(jthis);
@@ -176,9 +176,16 @@ Java_org_apache_subversion_javahl_SVNCli
   if (JNIUtil::isExceptionThrown())
     return;
 
+  StringArray patterns(jpatterns);
+  if (JNIUtil::isExceptionThrown())
+    return;
+
   ListCallback callback(jcallback);
-  cl->list(url, revision, pegRevision, EnumMapper::toDepth(jdepth),
-           static_cast<int>(jdirentFields), jfetchLocks ? true : false,
+  cl->list(url, revision, pegRevision, patterns,
+           EnumMapper::toDepth(jdepth),
+           static_cast<int>(jdirentFields),
+           jfetchLocks ? true : false,
+           jincludeExternals ? true : false,
            &callback);
 }
 

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=1785430&r1=1785429&r2=1785430&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
Sat Mar  4 06:16:58 2017
@@ -123,12 +123,30 @@ public interface ISVNClient
      * @param url             the url to list
      * @param revision        the revision to list
      * @param pegRevision     the revision to interpret url
+     * @param patterns        optional glob patterns to filter the result
      * @param depth           the depth to recurse into subdirectories
      * @param direntFields    the fields to retrieve
      * @param fetchLocks      whether to fetch lock information
+     * @param includeExternals whether to list external items
      * @param callback        the callback to receive the directory entries
+     * @since 1.10
      */
     void list(String url, Revision revision, Revision pegRevision,
+              List<String> patterns, Depth depth, int direntFields,
+              boolean fetchLocks, boolean includeExternals,
+              ListItemCallback callback)
+            throws ClientException;
+
+    /**
+     * Lists the directory entries of a url on the server.
+     * <p>
+     * Behaves like the 1.10 version with
+     *     <code>patterns = null</code> and
+     *     <code>includeExternals = false</code>
+     * @deprecated
+     */
+    @Deprecated
+    void list(String url, Revision revision, Revision pegRevision,
               Depth depth, int direntFields, boolean fetchLocks,
               ListCallback 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=1785430&r1=1785429&r2=1785430&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
Sat Mar  4 06:16:58 2017
@@ -141,11 +141,39 @@ public class SVNClient implements ISVNCl
                ignoreExternals, false, changelists, callback);
     }
 
-    public native void list(String url, Revision revision,
-                            Revision pegRevision, Depth depth, int direntFields,
-                            boolean fetchLocks, ListCallback callback)
+    public native void list(String url, Revision revision, Revision pegRevision,
+                            List<String> patterns, Depth depth, int direntFields,
+                            boolean fetchLocks, boolean includeExternals,
+                            ListItemCallback callback)
             throws ClientException;
 
+    private final class ListCallbackWrapper implements ListItemCallback
+    {
+        private final ListCallback wrappedCallback;
+
+        ListCallbackWrapper(ListCallback wrappedCallback)
+        {
+            this.wrappedCallback = wrappedCallback;
+        }
+
+        public void doEntry(DirEntry dirent, Lock lock,
+                            String externalParentURL,
+                            String externalTarget)
+        {
+            wrappedCallback.doEntry(dirent, lock);
+        }
+    };
+
+    @Deprecated
+    public void list(String url, Revision revision,
+                     Revision pegRevision, Depth depth, int direntFields,
+                     boolean fetchLocks, ListCallback callback)
+            throws ClientException
+    {
+        list(url, revision, pegRevision, null, depth, direntFields,
+             fetchLocks, false, new ListCallbackWrapper(callback));
+    }
+
     public native void username(String username);
 
     public native void password(String password);

Added: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ListItemCallback.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ListItemCallback.java?rev=1785430&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ListItemCallback.java
(added)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ListItemCallback.java
Sat Mar  4 06:16:58 2017
@@ -0,0 +1,48 @@
+/**
+ * @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.DirEntry;
+import org.apache.subversion.javahl.types.Lock;
+
+/**
+ * This interface is used to receive every directory entry
+ * returned from the {@link ISVNClient#list} call.
+ */
+public interface ListItemCallback
+{
+    /**
+     * This method will be called for each directory entry.
+     *
+     * If the entry is part of an external,
+     * <code>externalParentURL</code> will hold the URL of the
+     * external repository and <code>externalTarget</code> will be the
+     * target of the external reference in the working
+     * copy. Otherwise, both values will be <code>null</code>.
+     */
+    public void doEntry(DirEntry dirent, Lock lock,
+                        String externalParentURL,
+                        String externalTarget);
+}

Propchange: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/callback/ListItemCallback.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message