subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1509058 - in /subversion/branches/javahl-1.8-extensions: ./ subversion/bindings/javahl/ subversion/bindings/javahl/native/ subversion/bindings/javahl/src/org/apache/subversion/javahl/ subversion/bindings/javahl/src/org/apache/subversion/ja...
Date Thu, 01 Aug 2013 00:45:54 GMT
Author: brane
Date: Thu Aug  1 00:45:54 2013
New Revision: 1509058

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

Added:
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRangeList.cpp
      - copied unchanged from r1509057, subversion/trunk/subversion/bindings/javahl/native/RevisionRangeList.cpp
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRangeList.h
      - copied unchanged from r1509057, subversion/trunk/subversion/bindings/javahl/native/RevisionRangeList.h
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_types_RevisionRangeList.cpp
      - copied unchanged from r1509057, subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_types_RevisionRangeList.cpp
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/RevisionRangeList.java
      - copied unchanged from r1509057, subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/RevisionRangeList.java
Modified:
    subversion/branches/javahl-1.8-extensions/build.conf
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/   (props changed)
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/CreateJ.cpp
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/CreateJ.h
    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/RevisionRange.cpp
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRange.h
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_ConfigImpl_Category.cpp
    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/remote/RemoteSession.java
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/Mergeinfo.java
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
    subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNRemoteTests.java

Modified: subversion/branches/javahl-1.8-extensions/build.conf
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/build.conf?rev=1509058&r1=1509057&r2=1509058&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/build.conf (original)
+++ subversion/branches/javahl-1.8-extensions/build.conf Thu Aug  1 00:45:54 2013
@@ -63,6 +63,7 @@ private-built-includes =
         subversion/bindings/javahl/include/org_apache_subversion_javahl_types_VersionExtended_LoadedLib.h
         subversion/bindings/javahl/include/org_apache_subversion_javahl_types_VersionExtended_LoadedLibIterator.h
         subversion/bindings/javahl/include/org_apache_subversion_javahl_types_Revision.h
+        subversion/bindings/javahl/include/org_apache_subversion_javahl_types_RevisionRangeList.h
         subversion/bindings/javahl/include/org_apache_subversion_javahl_callback_UserPasswordCallback.h
         subversion/bindings/javahl/include/org_apache_subversion_javahl_remote_RemoteSession.h
         subversion/bindings/javahl/include/org_apache_subversion_javahl_remote_RemoteFactory.h

Propchange: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/
------------------------------------------------------------------------------
  Merged /subversion/trunk/subversion/bindings/javahl:r1507178-1509057

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/CreateJ.cpp?rev=1509058&r1=1509057&r2=1509058&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/CreateJ.cpp
(original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/CreateJ.cpp
Thu Aug  1 00:45:54 2013
@@ -30,6 +30,7 @@
 #include "JNIStringHolder.h"
 #include "EnumMapper.h"
 #include "RevisionRange.h"
+#include "RevisionRangeList.h"
 #include "CreateJ.h"
 #include "../include/org_apache_subversion_javahl_types_Revision.h"
 #include "../include/org_apache_subversion_javahl_CommitItemStateFlags.h"
@@ -1073,58 +1074,6 @@ CreateJ::CommitInfo(const svn_commit_inf
 }
 
 jobject
-CreateJ::RevisionRangeList(svn_rangelist_t *ranges)
-{
-  JNIEnv *env = JNIUtil::getEnv();
-
-  // Create a local frame for our references
-  env->PushLocalFrame(LOCAL_FRAME_SIZE);
-  if (JNIUtil::isJavaExceptionThrown())
-    return NULL;
-
-  jclass clazz = env->FindClass("java/util/ArrayList");
-  if (JNIUtil::isJavaExceptionThrown())
-    POP_AND_RETURN_NULL;
-
-  static jmethodID init_mid = 0;
-  if (init_mid == 0)
-    {
-      init_mid = env->GetMethodID(clazz, "<init>", "()V");
-      if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN_NULL;
-    }
-
-  static jmethodID add_mid = 0;
-  if (add_mid == 0)
-    {
-      add_mid = env->GetMethodID(clazz, "add", "(Ljava/lang/Object;)Z");
-      if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN_NULL;
-    }
-
-  jobject jranges = env->NewObject(clazz, init_mid);
-
-  for (int i = 0; i < ranges->nelts; ++i)
-    {
-      // Convert svn_merge_range_t *'s to Java RevisionRange objects.
-      svn_merge_range_t *range =
-          APR_ARRAY_IDX(ranges, i, svn_merge_range_t *);
-
-      jobject jrange = RevisionRange::makeJRevisionRange(range);
-      if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN_NULL;
-
-      env->CallBooleanMethod(jranges, add_mid, jrange);
-      if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN_NULL;
-
-      env->DeleteLocalRef(jrange);
-    }
-
-  return env->PopLocalFrame(jranges);
-}
-
-jobject
 CreateJ::StringSet(const apr_array_header_t *strings)
 {
   std::vector<jobject> jstrs;
@@ -1370,7 +1319,7 @@ jobject CreateJ::Mergeinfo(svn_mergeinfo
       jstring jpath =
         JNIUtil::makeJString(static_cast<const char*>(path));
       jobject jranges =
-        RevisionRangeList(static_cast<svn_rangelist_t*>(val));
+        RevisionRangeList(static_cast<svn_rangelist_t*>(val)).toList();
 
       env->CallVoidMethod(jmergeinfo, addRevisions, jpath, jranges);
 

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/CreateJ.h
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/CreateJ.h?rev=1509058&r1=1509057&r2=1509058&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/CreateJ.h
(original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/CreateJ.h
Thu Aug  1 00:45:54 2013
@@ -82,9 +82,6 @@ class CreateJ
   CommitInfo(const svn_commit_info_t *info);
 
   static jobject
-  RevisionRangeList(svn_rangelist_t *ranges);
-
-  static jobject
   StringSet(const apr_array_header_t *strings);
 
   static jobject

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=1509058&r1=1509057&r2=1509058&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 Aug  1 00:45:54 2013
@@ -924,7 +924,25 @@ RemoteSession::checkPath(jstring jpath, 
   return EnumMapper::mapNodeKind(kind);
 }
 
-// TODO: stat
+jobject
+RemoteSession::stat(jstring jpath, jlong jrevision)
+{
+  SVN::Pool subPool(pool);
+  Relpath path(jpath, subPool);
+  if (JNIUtil::isExceptionThrown())
+    return NULL;
+  SVN_JNI_ERR(path.error_occurred(), NULL);
+
+  svn_dirent_t* dirent;
+  SVN_JNI_ERR(svn_ra_stat(m_session, path.c_str(),
+                          svn_revnum_t(jrevision),
+                          &dirent, subPool.getPool()),
+              NULL);
+
+  if (dirent)
+    return CreateJ::DirEntry(path.c_str(), path.c_str(), dirent);
+  return NULL;
+}
 
 namespace {
 apr_array_header_t*
@@ -1057,7 +1075,114 @@ RemoteSession::getLocations(jstring jpat
   return location_hash_to_map(locations, subPool.getPool());
 }
 
-// TODO: getLocationSegments
+namespace {
+class LocationSegmentHandler
+{
+public:
+  static svn_error_t* callback(svn_location_segment_t* segment,
+                               void* baton, apr_pool_t*)
+    {
+      LocationSegmentHandler* const self =
+        static_cast<LocationSegmentHandler*>(baton);
+      SVN_ERR_ASSERT(self->m_jresult_list != NULL);
+      self->add(segment);
+      SVN_ERR(JNIUtil::checkJavaException(SVN_ERR_BASE));
+      return SVN_NO_ERROR;
+    }
+
+  LocationSegmentHandler()
+    : m_jresult_list(NULL)
+    {
+      JNIEnv* env = JNIUtil::getEnv();
+      jclass cls = env->FindClass("java/util/ArrayList");
+      if (JNIUtil::isJavaExceptionThrown())
+        return;
+
+      static jmethodID mid = 0;
+      if (mid == 0)
+        {
+          mid = env->GetMethodID(cls, "<init>", "()V");
+          if (JNIUtil::isJavaExceptionThrown())
+            return;
+        }
+
+      jobject jresult_list = env->NewObject(cls, mid);
+      if (!JNIUtil::isJavaExceptionThrown() && jresult_list)
+        m_jresult_list = jresult_list;
+    }
+
+  jobject get() const { return m_jresult_list; }
+
+private:
+  void add(svn_location_segment_t* segment)
+    {
+      JNIEnv* env = JNIUtil::getEnv();
+      jclass cls = env->FindClass(JAVA_PACKAGE"/ISVNRemote$LocationSegment");
+      if (JNIUtil::isJavaExceptionThrown())
+        return;
+
+      static jmethodID mid = 0;
+      if (mid == 0)
+        {
+          mid = env->GetMethodID(cls, "<init>",
+                                 "(Ljava/lang/String;JJ)V");
+          if (JNIUtil::isJavaExceptionThrown())
+            return;
+        }
+
+      static jmethodID mid_add = 0;
+      if (mid_add == 0)
+        {
+          jclass list_cls = env->FindClass("java/util/ArrayList");
+          if (JNIUtil::isJavaExceptionThrown())
+            return;
+          mid_add = env->GetMethodID(list_cls, "add",
+                                     "(Ljava/lang/Object;)Z");
+          if (JNIUtil::isJavaExceptionThrown())
+            return;
+        }
+
+      jstring jpath = JNIUtil::makeJString(segment->path);
+      if (JNIUtil::isJavaExceptionThrown())
+        return;
+
+      env->CallBooleanMethod(m_jresult_list, mid_add,
+                             env->NewObject(cls, mid, jpath,
+                                            jlong(segment->range_start),
+                                            jlong(segment->range_end)));
+      if (JNIUtil::isJavaExceptionThrown())
+        return;
+      env->DeleteLocalRef(jpath);
+    }
+
+  jobject m_jresult_list;
+};
+} // anonymous namespace
+
+jobject
+RemoteSession::getLocationSegments(jstring jpath, jlong jpeg_revision,
+                                   jlong jstart_revision, jlong jend_revision)
+{
+  SVN::Pool subPool(pool);
+  Relpath path(jpath, subPool);
+  if (JNIUtil::isExceptionThrown())
+    return NULL;
+  SVN_JNI_ERR(path.error_occurred(), NULL);
+
+  LocationSegmentHandler handler;
+  if (JNIUtil::isExceptionThrown())
+    return NULL;
+
+  SVN_JNI_ERR(svn_ra_get_location_segments(m_session, path.c_str(),
+                                           svn_revnum_t(jpeg_revision),
+                                           svn_revnum_t(jstart_revision),
+                                           svn_revnum_t(jend_revision),
+                                           handler.callback, &handler,
+                                           subPool.getPool()),
+              NULL);
+  return handler.get();
+}
+
 // TODO: getFileRevisions
 // TODO: lock
 // TODO: unlock

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=1509058&r1=1509057&r2=1509058&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 Aug  1 00:45:54 2013
@@ -92,10 +92,11 @@ class RemoteSession : public SVNBase
                 jboolean jinclude_merged_revisions,
                 jobject jrevprops, jobject jlog_callback);
     jobject checkPath(jstring jpath, jlong jrevision);
-    // TODO: stat
+    jobject stat(jstring jpath, jlong jrevision);
     jobject getLocations(jstring jpath, jlong jpeg_revision,
                          jobject jlocation_revisions);
-    // TODO: getLocationSegments
+    jobject getLocationSegments(jstring jpath, jlong jpeg_revision,
+                                jlong jstart_revision, jlong jend_revision);
     // TODO: getFileRevisions
     // TODO: lock
     // TODO: unlock

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRange.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRange.cpp?rev=1509058&r1=1509057&r2=1509058&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRange.cpp
(original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRange.cpp
Thu Aug  1 00:45:54 2013
@@ -44,60 +44,117 @@ RevisionRange::~RevisionRange()
     // explicitly destroyed.
 }
 
-const svn_opt_revision_range_t *RevisionRange::toRange(SVN::Pool &pool) const
+namespace {
+void get_range_info(jobject jrange,
+                    svn_opt_revision_t* range_start,
+                    svn_opt_revision_t* range_end,
+                    svn_boolean_t* range_inheritable)
 {
   JNIEnv *env = JNIUtil::getEnv();
 
   jclass clazz = env->FindClass(JAVA_PACKAGE"/types/RevisionRange");
   if (JNIUtil::isExceptionThrown())
-    return NULL;
+    return;
 
-  static jmethodID fmid = 0;
-  if (fmid == 0)
+  if (range_start)
     {
-      fmid = env->GetMethodID(clazz, "getFromRevision",
-                              "()L"JAVA_PACKAGE"/types/Revision;");
-      if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
+
+      static jmethodID fmid = 0;
+      if (fmid == 0)
+        {
+          fmid = env->GetMethodID(clazz, "getFromRevision",
+                                  "()L"JAVA_PACKAGE"/types/Revision;");
+          if (JNIUtil::isJavaExceptionThrown())
+            return;
+        }
+
+      jobject jstartRevision = env->CallObjectMethod(jrange, fmid);
+      if (JNIUtil::isExceptionThrown())
+        return;
+
+      Revision startRevision(jstartRevision);
+      if (JNIUtil::isExceptionThrown())
+        return;
+
+      *range_start = *startRevision.revision();
+      if (JNIUtil::isExceptionThrown())
+        return;
     }
 
-  static jmethodID tmid = 0;
-  if (tmid == 0)
+  if (range_end)
     {
-      tmid = env->GetMethodID(clazz, "getToRevision",
-                              "()L"JAVA_PACKAGE"/types/Revision;");
-      if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
+      static jmethodID tmid = 0;
+      if (tmid == 0)
+        {
+          tmid = env->GetMethodID(clazz, "getToRevision",
+                                  "()L"JAVA_PACKAGE"/types/Revision;");
+          if (JNIUtil::isJavaExceptionThrown())
+            return;
+        }
+
+      jobject jendRevision = env->CallObjectMethod(jrange, tmid);
+      if (JNIUtil::isExceptionThrown())
+        return;
+
+      Revision endRevision(jendRevision);
+      if (JNIUtil::isExceptionThrown())
+        return;
+
+      *range_end = *endRevision.revision();
+      if (JNIUtil::isExceptionThrown())
+        return;
     }
 
-  jobject jstartRevision = env->CallObjectMethod(m_range, fmid);
-  if (JNIUtil::isExceptionThrown())
-    return NULL;
+  if (range_inheritable)
+    {
+      static jmethodID imid = 0;
+      if (imid == 0 && range_inheritable)
+        {
+          imid = env->GetMethodID(clazz, "isInheritable", "()Z");
+          if (JNIUtil::isJavaExceptionThrown())
+            return;
+        }
+
+      jboolean inheritable = env->CallBooleanMethod(jrange, imid);
+      if (JNIUtil::isExceptionThrown())
+        return;
+      *range_inheritable = inheritable;
+    }
+}
+} // anonymous namespace
 
-  Revision startRevision(jstartRevision);
+svn_merge_range_t* RevisionRange::toMergeRange(SVN::Pool &pool) const
+{
+  svn_opt_revision_t range_start, range_end;
+  svn_boolean_t range_inheritable;
+  get_range_info(m_range, &range_start, &range_end, &range_inheritable);
   if (JNIUtil::isExceptionThrown())
     return NULL;
 
-  jobject jendRevision = env->CallObjectMethod(m_range, tmid);
-  if (JNIUtil::isExceptionThrown())
-    return NULL;
+  if (range_start.kind != svn_opt_revision_number
+      || range_end.kind != svn_opt_revision_number)
+    JNIUtil::raiseThrowable("java.lang.InvalidStateException",
+                            "Revsision ranges must contain revision numbers");
 
-  Revision endRevision(jendRevision);
-  if (JNIUtil::isExceptionThrown())
-    return NULL;
+  svn_merge_range_t* range =
+    static_cast<svn_merge_range_t*>
+      (apr_palloc(pool.getPool(), sizeof(*range)));
+
+  range->start = range_start.value.number;
+  range->end = range_end.value.number;
+  range->inheritable = range_inheritable;
+  return range;
+}
 
+svn_opt_revision_range_t *RevisionRange::toRange(SVN::Pool &pool) const
+{
   svn_opt_revision_range_t *range =
-    reinterpret_cast<svn_opt_revision_range_t *>
+    static_cast<svn_opt_revision_range_t *>
       (apr_palloc(pool.getPool(), sizeof(*range)));
 
-  range->start = *startRevision.revision();
-  if (JNIUtil::isExceptionThrown())
-    return NULL;
-
-  range->end = *endRevision.revision();
+  get_range_info(m_range, &range->start, &range->end, NULL);
   if (JNIUtil::isExceptionThrown())
-    return NULL;
-
+    range = NULL;
   return range;
 }
 

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRange.h
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRange.h?rev=1509058&r1=1509057&r2=1509058&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRange.h
(original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/RevisionRange.h
Thu Aug  1 00:45:54 2013
@@ -29,6 +29,7 @@
 
 #include <jni.h>
 #include "svn_types.h"
+#include "svn_opt.h"
 
 #include "Pool.h"
 
@@ -53,7 +54,12 @@ class RevisionRange
   /**
    * Return an svn_opt_revision_range_t.
    */
-  const svn_opt_revision_range_t *toRange(SVN::Pool &pool) const;
+  svn_opt_revision_range_t *toRange(SVN::Pool &pool) const;
+
+  /**
+   * Return an svn_merge_range_t.
+   */
+  svn_merge_range_t* toMergeRange(SVN::Pool &pool) const;
 
   /**
    * Make a (single) RevisionRange Java object.

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_ConfigImpl_Category.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_ConfigImpl_Category.cpp?rev=1509058&r1=1509057&r2=1509058&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_ConfigImpl_Category.cpp
(original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_ConfigImpl_Category.cpp
Thu Aug  1 00:45:54 2013
@@ -33,9 +33,9 @@
 #include "CreateJ.h"
 #include "EnumMapper.h"
 
+#include "svn_private_config.h"
 #include "svn_config.h"
 #include "svn_hash.h"
-#include "svn_private_config.h"
 
 #include <string>
 #include <vector>

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=1509058&r1=1509057&r2=1509058&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 Aug  1 00:45:54 2013
@@ -272,21 +272,42 @@ Java_org_apache_subversion_javahl_remote
   return ras->checkPath(jpath, jrevision);
 }
 
-// TODO: stat
+JNIEXPORT jobject JNICALL
+Java_org_apache_subversion_javahl_remote_RemoteSession_stat(
+    JNIEnv *env, jobject jthis, jstring jpath, jlong jrevision)
+{
+  JNIEntry(SVNReposAccess, stat);
+  RemoteSession *ras = RemoteSession::getCppObject(jthis);
+  CPPADDR_NULL_PTR(ras, NULL);
+
+  return ras->stat(jpath, jrevision);
+}
 
 JNIEXPORT jobject JNICALL
 Java_org_apache_subversion_javahl_remote_RemoteSession_getLocations(
     JNIEnv *env, jobject jthis, jstring jpath, jlong jpeg_revision,
     jobject jlocation_revisions)
 {
-  JNIEntry(SVNReposAccess, checkPath);
+  JNIEntry(SVNReposAccess, getLocations);
   RemoteSession *ras = RemoteSession::getCppObject(jthis);
   CPPADDR_NULL_PTR(ras, NULL);
 
   return ras->getLocations(jpath, jpeg_revision, jlocation_revisions);
 }
 
-// TODO: getLocationSegments
+JNIEXPORT jobject JNICALL
+Java_org_apache_subversion_javahl_remote_RemoteSession_getLocationSegments(
+    JNIEnv *env, jobject jthis, jstring jpath, jlong jpeg_revision,
+    jlong jstart_revision, jlong jend_revision)
+{
+  JNIEntry(SVNReposAccess, getLocationSegments);
+  RemoteSession *ras = RemoteSession::getCppObject(jthis);
+  CPPADDR_NULL_PTR(ras, NULL);
+
+  return ras->getLocationSegments(jpath, jpeg_revision,
+                                  jstart_revision, jend_revision);
+}
+
 // TODO: getFileRevisions
 // TODO: lock
 // TODO: unlock

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=1509058&r1=1509057&r2=1509058&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 Aug  1 00:45:54 2013
@@ -27,6 +27,7 @@ import org.apache.subversion.javahl.type
 import org.apache.subversion.javahl.callback.*;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.io.OutputStream;
@@ -433,14 +434,24 @@ public interface ISVNRemote
             throws ClientException;
 
     /**
-     * Return the kind of the node in path at revision.
+     * Return the kind of the node in <code>path</code> at
+     * <code>revision</code>.
      * @param path A path relative to the sessionn URL
      * @throws ClientException
      */
     NodeKind checkPath(String path, long revision)
             throws ClientException;
 
-    // TODO: stat
+    /**
+     * Return the directory entry object for <code>path</code> at
+     * <code>revision</code>.
+     * @param path A path relative to the sessionn URL
+     * @return A directory entry obeject, or <code>null</code> if
+     * <code>path</code> at <code>revision</code> does not exist.
+     * @throws ClientException
+     */
+    DirEntry stat(String path, long revision)
+            throws ClientException;
 
     /**
      * Find the locations of the object identified by
@@ -458,7 +469,69 @@ public interface ISVNRemote
                                    Iterable<Long> locationRevisions)
             throws ClientException;
 
-    // TODO: getLocationSegments
+    /**
+     * The object returned from {@link getLocationSegments}.
+     */
+    public static class LocationSegment implements java.io.Serializable
+    {
+        // Update the serialVersionUID when there is a incompatible change
+        // made to this class.
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * Private constructor called by the native implementation.
+         */
+        private LocationSegment(String path,
+                                long startRevision,
+                                long endRevision)
+        {
+            this.path = path;
+            this.startRevision = startRevision;
+            this.endRevision = endRevision;
+        }
+
+        /**
+         * @return The repository-relative path of the obejct in this
+         * history segment.
+         */
+        public String getPath() { return path; }
+
+        /**
+         * @return The start revision of the history segment.
+         */
+        public long getStartRevision() { return startRevision; }
+
+        /**
+         * @return The end revision of the history segment.
+         */
+        public long getEndRevision() { return endRevision; }
+
+        private String path;
+        private long startRevision;
+        private long endRevision;
+    }
+
+    /**
+     * Return a lost of segments in the location history of <code>path</code>
+     * at <code>pegRevision</code>, working backwards in time from
+     * <code>startRevision</code> to <code>endRevision</code>.
+     *
+     * @param path A session-relative path.
+     * @param pegRevision The peg revision to find <code>path</code> in.
+     * @param startRevision The upper bound of the revision range. Use
+     * {@link org.apache.subversion.javahl.types.Revision#SVN_INVALID_REVNUM}
+     *        to indicate HEAD.
+     * @param endRevision The lower bound of the revision range. Use
+     * {@link org.apache.subversion.javahl.types.Revision#SVN_INVALID_REVNUM}
+     *        to trace the history of the object to its origin.
+     * @throws ClientException
+     */
+    List<LocationSegment> getLocationSegments(String path,
+                                              long pegRevision,
+                                              long startRevision,
+                                              long endRevision)
+            throws ClientException;
+
     // TODO: getFileRevisions
     // TODO: lock
     // TODO: unlock

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=1509058&r1=1509057&r2=1509058&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 Aug  1 00:45:54 2013
@@ -35,6 +35,7 @@ import org.apache.subversion.javahl.Clie
 
 import java.lang.ref.WeakReference;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.io.OutputStream;
@@ -197,14 +198,21 @@ public class RemoteSession extends JNIOb
     public native NodeKind checkPath(String path, long revision)
             throws ClientException;
 
-    // TODO: stat
+    public native DirEntry stat(String path, long revision)
+            throws ClientException;
 
     public native Map<Long, String>
         getLocations(String path, long pegRevision,
                      Iterable<Long> locationRevisions)
             throws ClientException;
 
-    // TODO: getLocationSegments
+    public native
+        List<LocationSegment> getLocationSegments(String path,
+                                                  long pegRevision,
+                                                  long startRevision,
+                                                  long endRevision)
+            throws ClientException;
+
     // TODO: getFileRevisions
     // TODO: lock
     // TODO: unlock

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/Mergeinfo.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/Mergeinfo.java?rev=1509058&r1=1509057&r2=1509058&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/Mergeinfo.java
(original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/Mergeinfo.java
Thu Aug  1 00:45:54 2013
@@ -108,6 +108,11 @@ public class Mergeinfo implements java.i
             addRevisionRange(mergeSrc, range);
     }
 
+    public void addRevisions(String mergeSrc, RevisionRangeList ranges)
+    {
+        addRevisions(mergeSrc, ranges.getRanges());
+    }
+
     /**
      * Add a revision range to the merged revisions for a path.  If
      * the merge source already has associated revision ranges, add
@@ -156,6 +161,14 @@ public class Mergeinfo implements java.i
     }
 
     /**
+     * Like {@link #getReivsionRange}, but returns a {@link RevisionRangeList}.
+     */
+    public RevisionRangeList getRevisionRangeList(String mergeSrc)
+    {
+        return new RevisionRangeList(getRevisionRange(mergeSrc));
+    }
+
+    /**
      * Parse the <code>svn:mergeinfo</code> property to populate the
      * merge source URLs and revision ranges of this instance.
      * @param mergeinfo <code>svn:mergeinfo</code> property value.

Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java?rev=1509058&r1=1509057&r2=1509058&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
(original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
Thu Aug  1 00:45:54 2013
@@ -3744,6 +3744,39 @@ public class BasicTests extends SVNTests
     }
 
     /**
+     * Test RevisionRangeList.remove
+     */
+    public void testRevisionRangeListRemove() throws Throwable
+    {
+        RevisionRangeList ranges =
+            new RevisionRangeList(new ArrayList<RevisionRange>());
+        ranges.getRanges()
+            .add(new RevisionRange(Revision.getInstance(1),
+                                   Revision.getInstance(5),
+                                   true));
+        ranges.getRanges()
+            .add(new RevisionRange(Revision.getInstance(7),
+                                   Revision.getInstance(9),
+                                   false));
+        RevisionRangeList eraser =
+            new RevisionRangeList(new ArrayList<RevisionRange>());
+        eraser.getRanges()
+            .add(new RevisionRange(Revision.getInstance(7),
+                                   Revision.getInstance(9),
+                                   true));
+
+        List<RevisionRange> result = ranges.remove(eraser, true).getRanges();
+        assertEquals(2, ranges.getRanges().size());
+        assertEquals(1, eraser.getRanges().size());
+        assertEquals(2, result.size());
+
+        result = ranges.remove(eraser.getRanges(), false);
+        assertEquals(2, ranges.getRanges().size());
+        assertEquals(1, eraser.getRanges().size());
+        assertEquals(1, result.size());
+    }
+
+    /**
      * @return <code>file</code> converted into a -- possibly
      * <code>canonical</code>-ized -- Subversion-internal path
      * representation.

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=1509058&r1=1509057&r2=1509058&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 Aug  1 00:45:54 2013
@@ -170,6 +170,20 @@ public class SVNRemoteTests extends SVNT
         assertEquals(NodeKind.dir, kind);
     }
 
+    public void testStat() throws Exception
+    {
+        ISVNRemote session = getSession();
+
+        DirEntry dirent = session.stat("iota", 1);
+        assertEquals(NodeKind.file, dirent.getNodeKind());
+
+        dirent = session.stat("iota", 0);
+        assertNull(dirent);
+
+        dirent = session.stat("A", 1);
+        assertEquals(NodeKind.dir, dirent.getNodeKind());
+    }
+
     private String getTestRepoUrl()
     {
         return thisTest.getUrl().toASCIIString();
@@ -1099,4 +1113,19 @@ public class SVNRemoteTests extends SVNT
         assertTrue(locs.containsKey(expected));
         assertEquals("/A", locs.get(expected));
     }
+
+    public void testGetLocationSegments() throws Exception
+    {
+        ISVNRemote session = getSession();
+
+        List<ISVNRemote.LocationSegment> result =
+            session.getLocationSegments("A", 1,
+                                        Revision.SVN_INVALID_REVNUM,
+                                        Revision.SVN_INVALID_REVNUM);
+        assertEquals(1, result.size());
+        ISVNRemote.LocationSegment seg = result.get(0);
+        assertEquals("A", seg.getPath());
+        assertEquals(1, seg.getStartRevision());
+        assertEquals(1, seg.getEndRevision());
+    }
 }



Mime
View raw message