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 2014/06/18 17:27:14 UTC

svn commit: r1603481 - in /subversion/trunk/subversion/bindings/javahl: native/ src/org/apache/subversion/javahl/

Author: brane
Date: Wed Jun 18 15:27:13 2014
New Revision: 1603481

URL: http://svn.apache.org/r1603481
Log:
Remove the last trivially removable calls of deprecated functions from
JavaHL, and expose the related API changes.

[in subversion/bindings/javahl]
* src/org/apache/subversion/javahl/ISVNClient.java,
  src/org/apache/subversion/javahl/SVNClient.java
  (ISVNClient.revert): Add an overload that can optionally clear
   changelist data from reverted paths.
  (ISVNClient.streamFileContent): Add an overload that optionally
   expands keywords and returns (regular, not inherited) file
   properties.
  (ISVNClient.info): New; replaces the oh-so-appropriately named
   ...info2, and adds a knob to include or exclude externals
   in a recursive scan.

* native/SVNClient.h
  (SVNClient::info): Renamed from .info2, adds same options as the Java API.
  (SVNClient::streamFileContent, SVNClient::revert):
   Add same options as the equivalent updated Java APIs.
* native/SVNClient.cpp:
   As above, and change the method implementations to use:
     * svn_client_info4 instead of svn_client_info3;
     * svn_client_cat3 instead of svn_client_cat2;
     * svn_client_revert3 instead of svn_client_revert2.
* native/org_apache_subversion_javahl_SVNClient.cpp
  (Java_org_apache_subversion_javahl_SVNClient_revert,
   Java_org_apache_subversion_javahl_SVNClient_streamFileContent,
   Java_org_apache_subversion_javahl_SVNClient_info):
   Reflect changes in the Java API in the native method implementations.

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

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp?rev=1603481&r1=1603480&r2=1603481&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp Wed Jun 18 15:27:13 2014
@@ -338,7 +338,8 @@ void SVNClient::remove(Targets &targets,
 }
 
 void SVNClient::revert(StringArray &paths, svn_depth_t depth,
-                       StringArray &changelists)
+                       StringArray &changelists,
+                       bool clear_changelists)
 {
     SVN::Pool subPool(pool);
 
@@ -348,9 +349,10 @@ void SVNClient::revert(StringArray &path
 
     Targets targets(paths, subPool);
     SVN_JNI_ERR(targets.error_occurred(), );
-    SVN_JNI_ERR(svn_client_revert2(targets.array(subPool), depth,
-                                   changelists.array(subPool), ctx,
-                                   subPool.getPool()), );
+    SVN_JNI_ERR(svn_client_revert3(targets.array(subPool), depth,
+                                   changelists.array(subPool),
+                                   clear_changelists,
+                                   ctx, subPool.getPool()), );
 }
 
 void SVNClient::add(const char *path,
@@ -1100,23 +1102,31 @@ SVNClient::diffSummarize(const char *tar
                                                subPool.getPool()), );
 }
 
-void SVNClient::streamFileContent(const char *path, Revision &revision,
-                                  Revision &pegRevision,
-                                  OutputStream &outputStream)
+apr_hash_t *SVNClient::streamFileContent(const char *path,
+                                         Revision &revision,
+                                         Revision &pegRevision,
+                                         bool expand_keywords,
+                                         bool return_props,
+                                         OutputStream &outputStream)
 {
     SVN::Pool subPool(pool);
-    SVN_JNI_NULL_PTR_EX(path, "path", );
+    SVN_JNI_NULL_PTR_EX(path, "path", NULL);
     Path intPath(path, subPool);
-    SVN_JNI_ERR(intPath.error_occurred(), );
+    SVN_JNI_ERR(intPath.error_occurred(), NULL);
 
     svn_client_ctx_t *ctx = context.getContext(NULL, subPool);
     if (ctx == NULL)
-        return;
+        return NULL;
 
-    SVN_JNI_ERR(svn_client_cat2(outputStream.getStream(subPool),
-                                intPath.c_str(), pegRevision.revision(),
-                                revision.revision(), ctx, subPool.getPool()),
-                );
+    apr_hash_t *props = NULL;
+    SVN_JNI_ERR(svn_client_cat3((return_props ? &props : NULL),
+                                outputStream.getStream(subPool),
+                                intPath.c_str(),
+                                pegRevision.revision(), revision.revision(),
+                                expand_keywords, ctx,
+                                subPool.getPool(), subPool.getPool()),
+        NULL);
+    return props;
 }
 
 jbyteArray SVNClient::revProperty(const char *path,
@@ -1416,9 +1426,10 @@ jobject SVNClient::revProperties(const c
 }
 
 void
-SVNClient::info2(const char *path,
-                 Revision &revision, Revision &pegRevision, svn_depth_t depth,
-                 svn_boolean_t fetchExcluded, svn_boolean_t fetchActualOnly,
+SVNClient::info(const char *path,
+                Revision &revision, Revision &pegRevision, svn_depth_t depth,
+                svn_boolean_t fetchExcluded, svn_boolean_t fetchActualOnly,
+                svn_boolean_t includeExternals,
                  StringArray &changelists, InfoCallback *callback)
 {
     SVN_JNI_NULL_PTR_EX(path, "path", );
@@ -1431,10 +1442,11 @@ SVNClient::info2(const char *path,
     Path checkedPath(path, subPool);
     SVN_JNI_ERR(checkedPath.error_occurred(), );
 
-    SVN_JNI_ERR(svn_client_info3(checkedPath.c_str(),
+    SVN_JNI_ERR(svn_client_info4(checkedPath.c_str(),
                                  pegRevision.revision(),
-                                 revision.revision(),
-                                 depth, fetchExcluded, fetchActualOnly,
+                                 revision.revision(), depth,
+                                 fetchExcluded, fetchActualOnly,
+                                 includeExternals,
                                  changelists.array(subPool),
                                  InfoCallback::callback, callback,
                                  ctx, subPool.getPool()), );
@@ -1499,10 +1511,10 @@ SVNClient::openRemoteSession(const char*
           }
     } path_info;
 
-    SVN_JNI_ERR(svn_client_info3(
+    SVN_JNI_ERR(svn_client_info4(
                     checkedPath.c_str(), &NONE,
                     (svn_path_is_url(checkedPath.c_str()) ? &HEAD : &NONE),
-                    svn_depth_empty, FALSE, TRUE, NULL,
+                    svn_depth_empty, FALSE, TRUE, FALSE, NULL,
                     PathInfo::callback, &path_info,
                     ctx, subPool.getPool()),
                 NULL);

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.h?rev=1603481&r1=1603480&r2=1603481&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.h Wed Jun 18 15:27:13 2014
@@ -66,10 +66,11 @@ class SVNClient :public SVNBase
   void patch(const char *patchPath, const char *targetPath, bool dryRun,
              int stripCount, bool reverse, bool ignoreWhitespace,
              bool removeTempfiles, PatchCallback *callback);
-  void info2(const char *path,
-             Revision &revision, Revision &pegRevision, svn_depth_t depth,
-             svn_boolean_t fetchExcluded, svn_boolean_t fetchActualOnly,
-             StringArray &changelists, InfoCallback *callback);
+  void info(const char *path,
+            Revision &revision, Revision &pegRevision, svn_depth_t depth,
+            svn_boolean_t fetchExcluded, svn_boolean_t fetchActualOnly,
+            svn_boolean_t includeExternals,
+            StringArray &changelists, InfoCallback *callback);
   void unlock(Targets &targets, bool force);
   void lock(Targets &targets, const char *comment, bool force);
   jobject revProperties(const char *path, Revision &revision);
@@ -80,8 +81,10 @@ class SVNClient :public SVNBase
              BlameCallback *callback);
   void relocate(const char *from, const char *to, const char *path,
                 bool ignoreExternals);
-  void streamFileContent(const char *path, Revision &revision,
-                         Revision &pegRevision, OutputStream &outputStream);
+  apr_hash_t *streamFileContent(const char *path,
+                                Revision &revision, Revision &pegRevision,
+                                bool expand_keywords, bool return_props,
+                                OutputStream &outputStream);
   void propertySetLocal(Targets &targets, const char *name, JNIByteArray &value,
                         svn_depth_t depth, StringArray &changelists,
                         bool force);
@@ -148,7 +151,8 @@ class SVNClient :public SVNBase
                     bool allowUnverObstructions);
   void add(const char *path, svn_depth_t depth, bool force,
            bool no_ignore, bool no_autoprops, bool add_parents);
-  void revert(StringArray &paths, svn_depth_t depth, StringArray &changelists);
+  void revert(StringArray &paths, svn_depth_t depth, StringArray &changelists,
+              bool clear_changelists);
   void remove(Targets &targets, CommitMessage *message, bool force,
               bool keep_local, PropertyTable &revprops,
               CommitCallback *callback);

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=1603481&r1=1603480&r2=1603481&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 Wed Jun 18 15:27:13 2014
@@ -51,6 +51,7 @@
 #include "ChangelistCallback.h"
 #include "StringArray.h"
 #include "PropertyTable.h"
+#include "CreateJ.h"
 #include "VersionExtended.h"
 #include "DiffOptions.h"
 #include "svn_version.h"
@@ -438,7 +439,7 @@ Java_org_apache_subversion_javahl_SVNCli
 JNIEXPORT void JNICALL
 Java_org_apache_subversion_javahl_SVNClient_revert
 (JNIEnv *env, jobject jthis, jobject jpaths, jobject jdepth,
- jobject jchangelists)
+ jobject jchangelists, jboolean jclear_changelists)
 {
   JNIEntry(SVNClient, revert);
   SVNClient *cl = SVNClient::getCppObject(jthis);
@@ -457,7 +458,8 @@ Java_org_apache_subversion_javahl_SVNCli
   if (JNIUtil::isExceptionThrown())
     return;
 
-  cl->revert(paths, EnumMapper::toDepth(jdepth), changelists);
+  cl->revert(paths, EnumMapper::toDepth(jdepth),
+             changelists, bool(jclear_changelists));
 }
 
 JNIEXPORT void JNICALL
@@ -1488,35 +1490,44 @@ Java_org_apache_subversion_javahl_SVNCli
                     jignoreAncestry ? true : false, receiver);
 }
 
-JNIEXPORT void JNICALL
+JNIEXPORT jobject JNICALL
 Java_org_apache_subversion_javahl_SVNClient_streamFileContent
-(JNIEnv *env, jobject jthis, jstring jpath, jobject jrevision,
- jobject jpegRevision, jobject jstream)
+(JNIEnv *env, jobject jthis, jstring jpath,
+ jobject jrevision, jobject jpegRevision,
+ jboolean jexpand_keywords, jboolean jreturn_props,
+ jobject jstream)
 {
   JNIEntry(SVNClient, streamFileContent);
   SVNClient *cl = SVNClient::getCppObject(jthis);
   if (cl == NULL)
     {
       JNIUtil::throwError(_("bad C++ this"));
-      return;
+      return NULL;
     }
   JNIStringHolder path(jpath);
   if (JNIUtil::isExceptionThrown())
-    return;
+    return NULL;
 
   Revision revision(jrevision);
   if (JNIUtil::isExceptionThrown())
-    return;
+    return NULL;
 
   Revision pegRevision(jpegRevision);
   if (JNIUtil::isExceptionThrown())
-    return;
+    return NULL;
 
   OutputStream dataOut(jstream);
   if (JNIUtil::isExceptionThrown())
-    return;
+    return NULL;
+
+  apr_hash_t* props =
+    cl->streamFileContent(path, revision, pegRevision,
+                          bool(jexpand_keywords), bool(jreturn_props),
+                          dataOut);
+  if (!jreturn_props || JNIUtil::isExceptionThrown())
+    return NULL;
 
-  cl->streamFileContent(path, revision, pegRevision, dataOut);
+  return CreateJ::PropertyMap(props, SVN::Pool().getPool());
 }
 
 JNIEXPORT jstring JNICALL
@@ -1870,13 +1881,14 @@ Java_org_apache_subversion_javahl_SVNCli
 }
 
 JNIEXPORT void JNICALL
-Java_org_apache_subversion_javahl_SVNClient_info2
+Java_org_apache_subversion_javahl_SVNClient_info
 (JNIEnv *env, jobject jthis, jstring jpath, jobject jrevision,
  jobject jpegRevision, jobject jdepth,
  jboolean jfetchExcluded, jboolean jfetchActualOnly,
+ jboolean jincludeExternals,
  jobject jchangelists, jobject jinfoCallback)
 {
-  JNIEntry(SVNClient, info2);
+  JNIEntry(SVNClient, info);
   SVNClient *cl = SVNClient::getCppObject(jthis);
   if (cl == NULL)
     {
@@ -1900,9 +1912,10 @@ Java_org_apache_subversion_javahl_SVNCli
     return;
 
   InfoCallback callback(jinfoCallback);
-  cl->info2(path, revision, pegRevision, EnumMapper::toDepth(jdepth),
-            svn_boolean_t(jfetchExcluded), svn_boolean_t(jfetchActualOnly),
-            changelists, &callback);
+  cl->info(path, revision, pegRevision, EnumMapper::toDepth(jdepth),
+           svn_boolean_t(jfetchExcluded), svn_boolean_t(jfetchActualOnly),
+           svn_boolean_t(jincludeExternals),
+           changelists, &callback);
 }
 
 JNIEXPORT void 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=1603481&r1=1603480&r2=1603481&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 Wed Jun 18 15:27:13 2014
@@ -259,13 +259,28 @@ public interface ISVNClient
      * @param path      A set of paths to revert.
      * @param depth     the depth to recurse into subdirectories
      * @param changelists changelists to filter by
+     * @param clearChangelists If set, will clear changelist association
+     *                         from the reverted paths.
      * @throws ClientException
      * @since 1.9
      */
-    void revert(Set<String> paths, Depth depth, Collection<String> changelists)
+    void revert(Set<String> paths, Depth depth,
+                Collection<String> changelists,
+                boolean clearChangelists)
             throws ClientException;
 
     /**
+     * Reverts set of files or directories to a pristine state.
+     * <p>
+     * Behaves like the 1.9 version with <code>clearChangelists</code>
+     * set to <code>false</code>;
+     */
+    void revert(Set<String> paths, Depth depth,
+                Collection<String> changelists)
+            throws ClientException;
+
+
+    /**
      * Reverts a file to a pristine state.
      * @param path      path of the file.
      * @param depth     the depth to recurse into subdirectories
@@ -1203,6 +1218,9 @@ public interface ISVNClient
 
     /**
      * Retrieve the content of a file
+     *
+     * Always expands keywords and never returns properties.
+     *
      * @param path      the path of the file
      * @param revision  the revision to retrieve
      * @param pegRevision the revision to interpret path
@@ -1221,11 +1239,40 @@ public interface ISVNClient
      * @param revision    the revision to retrieve
      * @param pegRevision the revision at which to interpret the path
      * @param stream      the stream to write the file's content to
+     * @param returnProps whether to return the file's own (not inherited)
+     *                    properties dalong with the contents
+     * @return The file's properties if <code>returnProps</code> is
+     *         set (which may yield an empty map), otherwise
+     *         <code>null</code>.
+     * @throws ClientException
+     * @see java.io.PipedOutputStream
+     * @see java.io.PipedInputStream
+     * @since 1.9
+     */
+    Map<String, byte[]>
+        streamFileContent(String path,
+                          Revision revision, Revision pegRevision,
+                          boolean expandKeywords, boolean returnProps,
+                          OutputStream stream)
+        throws ClientException;
+
+    /**
+     * Write the file's content to the specified output stream.  If
+     * you need an InputStream, use a
+     * PipedInputStream/PipedOutputStream combination.
+     *
+     * Always expands keywords and never returns properties.
+     *
+     * @param path        the path of the file
+     * @param revision    the revision to retrieve
+     * @param pegRevision the revision at which to interpret the path
+     * @param stream      the stream to write the file's content to
      * @throws ClientException
      * @see java.io.PipedOutputStream
      * @see java.io.PipedInputStream
      */
-    void streamFileContent(String path, Revision revision, Revision pegRevision,
+    void streamFileContent(String path,
+                           Revision revision, Revision pegRevision,
                            OutputStream stream)
         throws ClientException;
 
@@ -1384,10 +1431,25 @@ public interface ISVNClient
      * @param fetchActualOnly when <code>true</code>, retrieve
      * information about node that are not versioned, but are still
      * tree conflicted.
+     * @param includeExternals Recurs into externals directories
      * @param changelists   if non-null, filter paths using changelists
      * @param callback      a callback to receive the infos retrieved
      * @since 1.9
      */
+    void info(String pathOrUrl,
+              Revision revision, Revision pegRevision, Depth depth,
+              boolean fetchExcluded, boolean fetchActualOnly,
+              boolean includeExternals,
+              Collection<String> changelists, InfoCallback callback)
+        throws ClientException;
+
+    /**
+     * Retrieve information about repository or working copy items.
+     * <p>
+     * Behaves like {@see ISVNClient#info} with
+     * <code>includeExternals</code> set to <code>fals</code>
+     * @since 1.9
+     */
     void info2(String pathOrUrl,
                Revision revision, Revision pegRevision, Depth depth,
                boolean fetchExcluded, boolean fetchActualOnly,

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=1603481&r1=1603480&r2=1603481&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 Wed Jun 18 15:27:13 2014
@@ -193,14 +193,22 @@ public class SVNClient implements ISVNCl
             throws ClientException;
 
     public native void revert(Set<String> paths, Depth depth,
-                              Collection<String> changelists)
+                              Collection<String> changelists,
+                              boolean clearChangelists)
             throws ClientException;
 
+    public void revert(Set<String> paths, Depth depth,
+                       Collection<String> changelists)
+            throws ClientException
+    {
+        revert(paths, depth, changelists, false);
+    }
+
     public void revert(String path, Depth depth,
                        Collection<String> changelists)
             throws ClientException
     {
-        revert(Collections.singleton(path), depth, changelists);
+        revert(Collections.singleton(path), depth, changelists, false);
     }
 
     public native void add(String path, Depth depth, boolean force,
@@ -610,15 +618,25 @@ public class SVNClient implements ISVNCl
     {
         ByteArrayOutputStream stream = new ByteArrayOutputStream();
 
-        streamFileContent(path, revision, pegRevision, stream);
+        streamFileContent(path, revision, pegRevision, true, false, stream);
         return stream.toByteArray();
     }
 
-    public native void streamFileContent(String path, Revision revision,
-                                         Revision pegRevision,
-                                         OutputStream stream)
+    public native Map<String, byte[]>
+        streamFileContent(String path,
+                          Revision revision, Revision pegRevision,
+                          boolean expandKeywords, boolean returnProps,
+                          OutputStream stream)
             throws ClientException;
 
+    public void streamFileContent(String path, Revision revision,
+                                  Revision pegRevision,
+                                  OutputStream stream)
+        throws ClientException
+    {
+        streamFileContent(path, revision, pegRevision, true, false, stream);
+    }
+
     public native void relocate(String from, String to, String path,
                                 boolean ignoreExternals)
             throws ClientException;
@@ -726,21 +744,33 @@ public class SVNClient implements ISVNCl
     public native void unlock(Set<String> paths, boolean force)
             throws ClientException;
 
-    public native void info2(String pathOrUrl, Revision revision,
-                             Revision pegRevision, Depth depth,
-                             boolean fetchExcluded, boolean fetchActualOnly,
-                             Collection<String> changelists,
-                             InfoCallback callback)
+    public native void info(String pathOrUrl, Revision revision,
+                            Revision pegRevision, Depth depth,
+                            boolean fetchExcluded, boolean fetchActualOnly,
+                            boolean includeExternals,
+                            Collection<String> changelists,
+                            InfoCallback callback)
             throws ClientException;
 
     public void info2(String pathOrUrl, Revision revision,
                       Revision pegRevision, Depth depth,
+                      boolean fetchExcluded, boolean fetchActualOnly,
+                      Collection<String> changelists,
+                      InfoCallback callback)
+            throws ClientException
+    {
+        info(pathOrUrl, revision, pegRevision, depth,
+             fetchExcluded, fetchActualOnly, false, changelists, callback);
+    }
+
+    public void info2(String pathOrUrl, Revision revision,
+                      Revision pegRevision, Depth depth,
                       Collection<String> changelists,
                       InfoCallback callback)
             throws ClientException
     {
-        info2(pathOrUrl, revision, pegRevision, depth,
-              false, true, changelists, callback);
+        info(pathOrUrl, revision, pegRevision, depth,
+             false, true, false, changelists, callback);
     }
 
     public native void patch(String patchPath, String targetPath,