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 16:22:57 UTC

svn commit: r1497370 - in /subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl: ./ native/ src/org/apache/subversion/javahl/ src/org/apache/subversion/javahl/remote/ tests/org/apache/subversion/javahl/

Author: brane
Date: Thu Jun 27 14:22:57 2013
New Revision: 1497370

URL: http://svn.apache.org/r1497370
Log:
On the javahl-1.8-extensions branch: Sync JavaHL with trunk up to r1497365.

Added:
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/UpdateReporter.java
      - copied unchanged from r1497365, subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/UpdateReporter.java
Modified:
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/   (props changed)
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RemoteSession.cpp
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RemoteSession.h
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNReporter.java
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java

Propchange: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/
------------------------------------------------------------------------------
  Merged /subversion/trunk/subversion/bindings/javahl:r1497317-1497365

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RemoteSession.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RemoteSession.cpp?rev=1497370&r1=1497369&r2=1497370&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RemoteSession.cpp (original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RemoteSession.cpp Thu Jun 27 14:22:57 2013
@@ -38,11 +38,14 @@
 
 #include "CreateJ.h"
 #include "EnumMapper.h"
+#include "Iterator.h"
+#include "LogMessageCallback.h"
 #include "OutputStream.h"
 #include "Prompter.h"
 #include "Revision.h"
 #include "RemoteSession.h"
 
+#include <apr_strings.h>
 #include "svn_private_config.h"
 
 #define JAVA_CLASS_REMOTE_SESSION JAVA_PACKAGE "/remote/RemoteSession"
@@ -640,7 +643,75 @@ RemoteSession::status(jstring jstatus_ta
 }
 
 // TODO: diff
-// TODO: getLog
+
+namespace {
+const apr_array_header_t*
+build_string_array(const Iterator& iter,
+                   bool contains_relpaths, SVN::Pool& pool)
+{
+  apr_pool_t* result_pool = pool.getPool();
+  apr_array_header_t* array = apr_array_make(
+      result_pool, 0, sizeof(const char*));
+  while (iter.hasNext())
+    {
+      const char* element;
+      jstring jitem = (jstring)iter.next();
+      if (contains_relpaths)
+        {
+          Relpath item(jitem, pool);
+          if (JNIUtil::isExceptionThrown())
+            return NULL;
+          SVN_JNI_ERR(item.error_occurred(), NULL);
+          element = apr_pstrdup(result_pool, item.c_str());
+        }
+      else
+        {
+          JNIStringHolder item(jitem);
+          if (JNIUtil::isJavaExceptionThrown())
+            return NULL;
+          element = item.pstrdup(result_pool);
+        }
+      APR_ARRAY_PUSH(array, const char*) = element;
+    }
+  return array;
+}
+}
+
+void
+RemoteSession::getLog(jobject jpaths,
+                      jlong jstartrev, jlong jendrev, jint jlimit,
+                      jboolean jstop_on_copy, jboolean jdiscover_changed_paths,
+                      jboolean jinclude_merged_revisions,
+                      jobject jrevprops, jobject jlog_callback)
+{
+  Iterator pathiter(jpaths);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+  Iterator revpropiter(jrevprops);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+  LogMessageCallback receiver(jlog_callback);
+
+  SVN::Pool subPool(pool);
+  const apr_array_header_t* paths = build_string_array(pathiter,
+                                                       true, subPool);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+  const apr_array_header_t* revprops = build_string_array(revpropiter,
+                                                          false, subPool);
+  if (JNIUtil::isJavaExceptionThrown())
+    return;
+
+  SVN_JNI_ERR(svn_ra_get_log2(m_session, paths,
+                              svn_revnum_t(jstartrev), svn_revnum_t(jendrev),
+                              int(jlimit),
+                              bool(jdiscover_changed_paths),
+                              bool(jstop_on_copy),
+                              bool(jinclude_merged_revisions),
+                              revprops,
+                              receiver.callback, &receiver,
+                              subPool.getPool()),);
+}
 
 jobject
 RemoteSession::checkPath(jstring jpath, jlong jrevision)

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RemoteSession.h
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RemoteSession.h?rev=1497370&r1=1497369&r2=1497370&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RemoteSession.h (original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RemoteSession.h Thu Jun 27 14:22:57 2013
@@ -84,7 +84,10 @@ class RemoteSession : public SVNBase
                    jlong jrevision, jobject jdepth,
                    jobject jstatus_editor);
     // TODO: diff
-    // TODO: getLog
+    void getLog(jobject jpaths, jlong jstartrev, jlong jendrev, jint jlimit,
+                jboolean jstop_on_copy, jboolean jdiscover_changed_paths,
+                jboolean jinclude_merged_revisions,
+                jobject jrevprops, jobject jlog_callback);
     jobject checkPath(jstring jpath, jlong jrevision);
     // TODO: stat
     // TODO: getLocations

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp?rev=1497370&r1=1497369&r2=1497370&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp (original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp Thu Jun 27 14:22:57 2013
@@ -230,7 +230,24 @@ Java_org_apache_subversion_javahl_remote
 }
 
 // TODO: diff
-// TODO: getLog
+
+JNIEXPORT void JNICALL
+Java_org_apache_subversion_javahl_remote_RemoteSession_getLog(
+    JNIEnv *env, jobject jthis, jobject jpaths,
+    jlong jstartrev, jlong jendrev, jint jlimit,
+    jboolean jstop_on_copy, jboolean jdiscover_changed_paths,
+    jboolean jinclude_merged_revisions,
+    jobject jrevprops, jobject jlog_callback)
+{
+  JNIEntry(SVNReposAccess, getLog);
+  RemoteSession *ras = RemoteSession::getCppObject(jthis);
+  CPPADDR_NULL_PTR(ras,);
+
+  ras->getLog(jpaths, jstartrev, jendrev, jlimit,
+              jstop_on_copy, jdiscover_changed_paths,
+              jinclude_merged_revisions,
+              jrevprops, jlog_callback);
+}
 
 JNIEXPORT jobject JNICALL
 Java_org_apache_subversion_javahl_remote_RemoteSession_checkPath(

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java?rev=1497370&r1=1497369&r2=1497370&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java (original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNRemote.java Thu Jun 27 14:22:57 2013
@@ -336,7 +336,70 @@ public interface ISVNRemote
             throws ClientException;
 
     // TODO: diff
-    // TODO: getLog
+
+    /**
+     * Invoke <code>callback</code> for each log message from
+     * <code>start</code> to <code>end</code>.  <code>start</code> may be greater or less than <code>end</code>;
+     * this just controls whether the log messages are processed in descending
+     * or ascending revision number order.
+     * <p>
+     * If <code>start</code> or <code>end</code> is
+     * {@link org.apache.subversion.javahl.types.Revision#SVN_INVALID_REVNUM},
+     * the HEAD revision is uses for that argument. If eiter is an
+     * invaild non-existent revision, an error will be returned.
+     * <p>
+     * If <code>paths</code> is not <code>null</code> and has one or
+     * more elements, then only show revisions in which at least one
+     * of <code>paths</code> was changed (i.e., if file, text or props
+     * changed; if dir, props changed or an entry was added or
+     * deleted).
+     * <p>
+     * If <code>limit</code> is non-zero only invoke @a receiver on
+     * the first code>limit</code> logs.
+     * <p>
+     * If <code>discoverPath</code> is set, then each call to
+     * <code>callback</code> the list of changed paths in that
+     * revision.
+     * <p>
+     * If <code>stopOnCopy</code> is set, copy history will not be
+     * traversed (if any exists) when harvesting the revision logs for
+     * each path.
+     * <p>
+     * If <code>includeMergedRevisions</code> is set, log information
+     * for revisions which have been merged to @a targets will also be
+     * returned.
+     * <p>
+     * If <code>revisionProperties</code> is <code>null</code>,
+     * retrieve all revision properties; otherwise, retrieve only the
+     * revision properties contained in the set (i.e. retrieve none if
+     * the set is empty).
+     * <p>
+     * The implementation of <code>callback</code> may not perform any
+     * operations using this session. If the invocation of
+     * <code>callback</code> throws an exception, the operation will
+     * stop.
+     * <p>
+     * <b>Note:</b> If <code>paths</code> is <code>null</code> or
+     * empty, the result depends on the server.  Pre-1.5 servers will
+     * send nothing; 1.5 servers will effectively perform the log
+     * operation on the root of the repository.  This behavior may be
+     * changed in the future to ensure consistency across all
+     * pedigrees of server.
+     * <p>
+     * <b>Note:</b> Pre-1.5 servers do not support custom revprop
+     * retrieval; <code>revisionProperties</code> is <code>null</code>
+     * or contains a revprop other than svn:author, svn:date, or
+     * svn:log, an not-implemented error is returned.
+     *
+     * @throws ClientException
+     */
+    void getLog(Iterable<String> paths,
+                long startRevision, long endRevision, int limit,
+                boolean stopOnCopy, boolean discoverPath,
+                boolean includeMergedRevisions,
+                Iterable<String> revisionProperties,
+                LogMessageCallback callback)
+            throws ClientException;
 
     /**
      * Return the kind of the node in path at revision.

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNReporter.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNReporter.java?rev=1497370&r1=1497369&r2=1497370&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNReporter.java (original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNReporter.java Thu Jun 27 14:22:57 2013
@@ -53,6 +53,12 @@ import org.apache.subversion.javahl.call
 public interface ISVNReporter
 {
     /**
+     * Release the native peer (should not depend on finalize),
+     * and abort the report if it has not been completed yet.
+     */
+    void dispose();
+
+    /**
      * Describe a working copy <code>path</code> as being at a
      * particular <code>revision</code> and having the given
      * <code>depth</code>.

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java?rev=1497370&r1=1497369&r2=1497370&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java (original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/remote/RemoteSession.java Thu Jun 27 14:22:57 2013
@@ -161,7 +161,14 @@ public class RemoteSession extends JNIOb
             throws ClientException;
 
     // TODO: diff
-    // TODO: getLog
+
+    public native void getLog(Iterable<String> paths,
+                              long startRevision, long endRevision, int limit,
+                              boolean stopOnCopy, boolean discoverPath,
+                              boolean includeMergedRevisions,
+                              Iterable<String> revisionProperties,
+                              LogMessageCallback callback)
+            throws ClientException;
 
     public native NodeKind checkPath(String path, long revision)
             throws ClientException;

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java?rev=1497370&r1=1497369&r2=1497370&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java (original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java Thu Jun 27 14:22:57 2013
@@ -680,6 +680,70 @@ public class SVNRemoteTests extends SVNT
         } finally {
             cc.editor.dispose();
         }
+    }
+
+    private static final class LogMsg
+    {
+        public Set<ChangePath> changedPaths;
+        public long revision;
+        public Map<String, byte[]> revprops;
+        public boolean hasChildren;
+    }
+
+    private static final class LogReceiver implements LogMessageCallback
+    {
+        public final ArrayList<LogMsg> logs = new ArrayList<LogMsg>();
+
+        public void singleMessage(Set<ChangePath> changedPaths,
+                                  long revision,
+                                  Map<String, byte[]> revprops,
+                                  boolean hasChildren)
+        {
+            LogMsg msg = new LogMsg();
+            msg.changedPaths = changedPaths;
+            msg.revision = revision;
+            msg.revprops = revprops;
+            msg.hasChildren = hasChildren;
+            logs.add(msg);
+        }
+    }
+
+    public void testGetLog() throws Exception
+    {
+        ISVNRemote session = getSession();
+        LogReceiver receiver = new LogReceiver();
+
+        session.getLog(null,
+                       Revision.SVN_INVALID_REVNUM,
+                       Revision.SVN_INVALID_REVNUM,
+                       0, false, false, false, null,
+                       receiver);
+
+        assertEquals(1, receiver.logs.size());
+    }
+
+    public void testGetLogMissing() throws Exception
+    {
+        ISVNRemote session = getSession();
+        LogReceiver receiver = new LogReceiver();
+
+        ArrayList<String> paths = new ArrayList<String>(1);
+        paths.add("X");
+
+        boolean exception = false;
+        try {
+            session.getLog(paths,
+                           Revision.SVN_INVALID_REVNUM,
+                           Revision.SVN_INVALID_REVNUM,
+                           0, false, false, false, null,
+                           receiver);
+        } catch (ClientException ex) {
+            assertEquals("Filesystem has no item",
+                         ex.getAllMessages().get(0).getMessage());
+            exception = true;
+        }
 
+        assertEquals(0, receiver.logs.size());
+        assertTrue(exception);
     }
 }