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/03/12 17:39:49 UTC

svn commit: r1576813 - in /subversion/trunk/subversion/bindings/javahl: native/CreateJ.cpp src/org/apache/subversion/javahl/types/Status.java tests/org/apache/subversion/javahl/BasicTests.java

Author: brane
Date: Wed Mar 12 16:39:49 2014
New Revision: 1576813

URL: http://svn.apache.org/r1576813
Log:
in JavaHL, expose the raw values of node status, text status and
depth through new getters in the Status class, keeping the previous
cooked text status value identical.

[in subversion/bindings/javahl]
* src/org/apache/subversion/javahl/types/Status.java
  (Status.serialVersionUID): Bump the serialization identifier.
  (Status.nodeStatus, Status.repositoryNodeStatus, Status.depth):
   New private members.
  (Status.Status): New variant of the constructor that accepts
   values for the new members. The previous constructor is now
   marked as deprecated.
  (Status.getNodeStatus,
  Status.getNodeStatusDescription,
   Status.getRawTextStatus,
   Status.getRawTextStatusDescription,
   Status.getRepositoryNodeStatus,
   Status.getRawRepositoryTextStatus,
   Status.getDepth): New accessors.
  (Status.getTextStatus, Status.getRepositoryTextStatus): Reproduce the
   code that used to conflate the node and text status value in the
   native implementation (see below).
  (Status.isManaged, Status.hasRemote, Status.isAdded,
   Status.isDeleted, Status.isMerged, Status.isIgnored):
   Reiplement using getNodeStatus instead of getTextStatus.

* native/CreateJ.cpp (CreateJ::Status):
   Expose node and text status, both local and repository-side,
   as their raw values. Remove the code that used to conflate the
   text status with the node status value.

* tests/org/apache/subversion/javahl/BasicTests.java
  (BasicTests.testBasicStatus): Change the test condition to use
   the new node status values instead of the cooked text status.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
    subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/Status.java
    subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp?rev=1576813&r1=1576812&r2=1576813&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp Wed Mar 12 16:39:49 2014
@@ -631,7 +631,10 @@ CreateJ::Status(svn_wc_context_t *wc_ctx
                              "L"JAVA_PACKAGE"/types/Status$Kind;"
                              "L"JAVA_PACKAGE"/types/Status$Kind;"
                              "L"JAVA_PACKAGE"/types/Status$Kind;"
-                             "ZZZZZL"JAVA_PACKAGE"/types/Lock;"
+                             "L"JAVA_PACKAGE"/types/Status$Kind;"
+                             "L"JAVA_PACKAGE"/types/Status$Kind;"
+                             "ZZL"JAVA_PACKAGE"/types/Depth;"
+                             "ZZZL"JAVA_PACKAGE"/types/Lock;"
                              "L"JAVA_PACKAGE"/types/Lock;"
                              "JJL"JAVA_PACKAGE"/types/NodeKind;"
                              "Ljava/lang/String;Ljava/lang/String;"
@@ -657,27 +660,16 @@ CreateJ::Status(svn_wc_context_t *wc_ctx
   jstring jMovedFromAbspath = NULL;
   jstring jMovedToAbspath = NULL;
 
-  enum svn_wc_status_kind text_status = status->node_status;
-
-  /* Avoid using values that might come from prop changes */
-  if (text_status == svn_wc_status_modified
-      || text_status == svn_wc_status_conflicted)
-    text_status = status->text_status;
-
-  enum svn_wc_status_kind repos_text_status = status->repos_node_status;
-
-  if (repos_text_status == svn_wc_status_modified
-      || repos_text_status == svn_wc_status_conflicted)
-    repos_text_status = status->repos_text_status;
-
-  jboolean jIsConflicted = (status->conflicted == 1) ? JNI_TRUE : JNI_FALSE;
-  jobject jTextType = EnumMapper::mapStatusKind(text_status);
+  jobject jNodeType = EnumMapper::mapStatusKind(status->node_status);
+  jobject jTextType = EnumMapper::mapStatusKind(status->text_status);
   jobject jPropType = EnumMapper::mapStatusKind(status->prop_status);
-  jobject jRepositoryTextType = EnumMapper::mapStatusKind(repos_text_status);
-  jobject jRepositoryPropType = EnumMapper::mapStatusKind(
-                                                  status->repos_prop_status);
-  jboolean jIsCopied = (status->copied == 1) ? JNI_TRUE: JNI_FALSE;
+  jobject jRpNodeType = EnumMapper::mapStatusKind(status->repos_node_status);
+  jobject jRpTextType = EnumMapper::mapStatusKind(status->repos_text_status);
+  jobject jRpPropType = EnumMapper::mapStatusKind(status->repos_prop_status);
+  jobject jDepth = EnumMapper::mapDepth(status->depth);
   jboolean jIsLocked = (status->wc_is_locked == 1) ? JNI_TRUE: JNI_FALSE;
+  jboolean jIsCopied = (status->copied == 1) ? JNI_TRUE: JNI_FALSE;
+  jboolean jIsConflicted = (status->conflicted == 1) ? JNI_TRUE : JNI_FALSE;
   jboolean jIsSwitched = (status->switched == 1) ? JNI_TRUE: JNI_FALSE;
   jboolean jIsFileExternal = (status->file_external == 1) ? JNI_TRUE
                                                           : JNI_FALSE;
@@ -743,9 +735,10 @@ CreateJ::Status(svn_wc_context_t *wc_ctx
 
   jobject ret = env->NewObject(clazz, mid, jPath, jUrl, jNodeKind, jRevision,
                                jLastChangedRevision, jLastChangedDate,
-                               jLastCommitAuthor, jTextType, jPropType,
-                               jRepositoryTextType, jRepositoryPropType,
-                               jIsLocked, jIsCopied, jIsConflicted,
+                               jLastCommitAuthor,
+                               jNodeType, jTextType, jPropType,
+                               jRpNodeType, jRpTextType, jRpPropType,
+                               jIsLocked, jIsCopied, jDepth, jIsConflicted,
                                jIsSwitched, jIsFileExternal, jLocalLock,
                                jReposLock,
                                jOODLastCmtRevision, jOODLastCmtDate,

Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/Status.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/Status.java?rev=1576813&r1=1576812&r2=1576813&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/Status.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/types/Status.java Wed Mar 12 16:39:49 2014
@@ -38,7 +38,7 @@ public class Status implements java.io.S
     // Update the serialVersionUID when there is a incompatible change made to
     // this class.  See the java documentation for when a change is incompatible.
     // http://java.sun.com/javase/7/docs/platform/serialization/spec/version.html#6678
-    private static final long serialVersionUID = 2L;
+    private static final long serialVersionUID = 3L;
 
     /**
      * the url for accessing the item
@@ -77,12 +77,19 @@ public class Status implements java.io.S
     private String lastCommitAuthor;
 
     /**
-     * the file or directory status (See StatusKind)
+     * The status of the node, based on restructuring changes; if the node
+     * has no restructuring changes, it's based on textStatus and propStatus.
+     * @since 1.9
+     */
+    private Kind nodeStatus;
+
+    /**
+     * The file or directory status, not including restructuring changes.
      */
     private Kind textStatus;
 
     /**
-     * the status of the properties (See StatusKind)
+     * The status of the properties.
      */
     private Kind propStatus;
 
@@ -108,11 +115,24 @@ public class Status implements java.io.S
     private boolean fileExternal;
 
     /**
+     * The depth of the node as recorded in the working copy.
+     * @since 1.9
+     */
+    private Depth depth;
+
+    /**
      * is this item in a conflicted state
      */
     private boolean isConflicted;
 
     /**
+     * The status of the node, based on text and property status, unless the
+     * node has restructuring changes.
+     * @since 1.9
+     */
+    private Kind repositoryNodeStatus;
+
+    /**
      * the file or directory status of base (See StatusKind)
      */
     private Kind repositoryTextStatus;
@@ -164,7 +184,6 @@ public class Status implements java.io.S
     private String movedFromAbspath;
 
     private String movedToAbspath;
-
     /**
      * this constructor should only called from JNI code
      * @param path                  the file system path of item
@@ -174,22 +193,17 @@ public class Status implements java.io.S
      * @param lastChangedRevision   the last revision this item was changed
      * @param lastChangedDate       the last date this item was changed
      * @param lastCommitAuthor      the author of the last change
-     * @param textStatus            the file or directory status (See
-     *                              StatusKind)
-     * @param propStatus            the property status (See StatusKind)
-     * @param repositoryTextStatus  the file or directory status of the base
+     * @param nodeStatus            the status of the node
+     * @param textStatus            the file or directory contents status
+     * @param propStatus            the property status
+     * @param repositoryNodeStatus  the status of the base node
+     * @param repositoryTextStatus  the file or directory contents status of the base
      * @param repositoryPropStatus  the property status of the base
      * @param locked                if the item is locked (running or aborted
      *                              operation)
      * @param copied                if the item is copy
+     * @param depth                 the inherent depth of the node in the working copy
      * @param isConflicted          if the item is part of a conflict
-     * @param conflictDescriptor    the description of the tree conflict
-     * @param conflictOld           in case of conflict, the file name of the
-     *                              the common base version
-     * @param conflictNew           in case of conflict, the file name of new
-     *                              repository version
-     * @param conflictWorking       in case of conflict, the file name of the
-     *                              former working copy version
      * @param switched              flag if the node has been switched in the
      *                              path
      * @param fileExternal          flag if the node is a file external
@@ -205,12 +219,16 @@ public class Status implements java.io.S
      * @param changelist            the changelist the item is a member of
      * @param movedFromAbspath      path moved from
      * @param movedToAbspath        path moved from
+     * @since 1.9
      */
     public Status(String path, String url, NodeKind nodeKind, long revision,
                   long lastChangedRevision, long lastChangedDate,
-                  String lastCommitAuthor, Kind textStatus, Kind propStatus,
+                  String lastCommitAuthor,
+                  Kind nodeStatus, Kind textStatus, Kind propStatus,
+                  Kind repositoryNodeStatus,
                   Kind repositoryTextStatus, Kind repositoryPropStatus,
-                  boolean locked, boolean copied, boolean isConflicted,
+                  boolean locked, boolean copied, Depth depth,
+                  boolean isConflicted,
                   boolean switched, boolean fileExternal, Lock localLock,
                   Lock reposLock, long reposLastCmtRevision,
                   long reposLastCmtDate, NodeKind reposKind,
@@ -224,13 +242,16 @@ public class Status implements java.io.S
         this.lastChangedRevision = lastChangedRevision;
         this.lastChangedDate = lastChangedDate;
         this.lastCommitAuthor = lastCommitAuthor;
+        this.nodeStatus = nodeStatus;
         this.textStatus = textStatus;
         this.propStatus = propStatus;
+        this.repositoryNodeStatus = repositoryNodeStatus;
+        this.repositoryTextStatus = repositoryTextStatus;
+        this.repositoryPropStatus = repositoryPropStatus;
         this.locked = locked;
         this.copied = copied;
+        this.depth = depth;
         this.isConflicted = isConflicted;
-        this.repositoryTextStatus = repositoryTextStatus;
-        this.repositoryPropStatus = repositoryPropStatus;
         this.switched = switched;
         this.fileExternal = fileExternal;
         this.localLock = localLock;
@@ -245,6 +266,64 @@ public class Status implements java.io.S
     }
 
     /**
+     * this constructor should only called from JNI code
+     * @param path                  the file system path of item
+     * @param url                   the url of the item
+     * @param nodeKind              kind of item (directory, file or unknown
+     * @param revision              the revision number of the base
+     * @param lastChangedRevision   the last revision this item was changed
+     * @param lastChangedDate       the last date this item was changed
+     * @param lastCommitAuthor      the author of the last change
+     * @param textStatus            the file or directory status (See
+     *                              StatusKind)
+     * @param propStatus            the property status (See StatusKind)
+     * @param repositoryTextStatus  the file or directory status of the base
+     * @param repositoryPropStatus  the property status of the base
+     * @param locked                if the item is locked (running or aborted
+     *                              operation)
+     * @param copied                if the item is copy
+     * @param isConflicted          if the item is part of a conflict
+     * @param switched              flag if the node has been switched in the
+     *                              path
+     * @param fileExternal          flag if the node is a file external
+     * @param localLock             the current lock
+     * @param reposLock             the lock as stored in the repository if
+     *                              any
+     * @param reposLastCmtRevision  the youngest revision, if out of date
+     * @param reposLastCmtDate      the last commit date, if out of date
+     * @param reposKind             the kind of the youngest revision, if
+     *                              out of date
+     * @param reposLastCmtAuthor    the author of the last commit, if out of
+     *                              date
+     * @param changelist            the changelist the item is a member of
+     * @param movedFromAbspath      path moved from
+     * @param movedToAbspath        path moved from
+     * @deprecated
+     */
+    @Deprecated
+    public Status(String path, String url, NodeKind nodeKind, long revision,
+                  long lastChangedRevision, long lastChangedDate,
+                  String lastCommitAuthor, Kind textStatus, Kind propStatus,
+                  Kind repositoryTextStatus, Kind repositoryPropStatus,
+                  boolean locked, boolean copied, boolean isConflicted,
+                  boolean switched, boolean fileExternal, Lock localLock,
+                  Lock reposLock, long reposLastCmtRevision,
+                  long reposLastCmtDate, NodeKind reposKind,
+                  String reposLastCmtAuthor, String changelist,
+                  String movedFromAbspath, String movedToAbspath)
+    {
+        this(path, url, nodeKind, revision,
+             lastChangedRevision, lastChangedDate, lastCommitAuthor,
+             Kind.none, textStatus, propStatus,
+             Kind.none, repositoryTextStatus, repositoryPropStatus,
+             locked, copied, Depth.unknown, isConflicted,
+             switched, fileExternal, localLock, reposLock,
+             reposLastCmtRevision, reposLastCmtDate, reposKind,
+             reposLastCmtAuthor, changelist,
+             movedFromAbspath, movedToAbspath);
+    }
+
+    /**
      * Returns the file system path of the item
      * @return path of status entry
      */
@@ -301,25 +380,64 @@ public class Status implements java.io.S
     }
 
     /**
-     * Returns the status of the item (See StatusKind)
+     * Returns the status of the node.
+     * @since 1.9
+     */
+    public Kind getNodeStatus()
+    {
+        return nodeStatus;
+    }
+
+    /**
+     * Returns the status of the node as text.
+     * @since 1.9
+     */
+    public String getNodeStatusDescription()
+    {
+        return nodeStatus.toString();
+    }
+
+    /**
+     * Returns the real status of the item's contents.
+     * @since 1.9
+     */
+    public Kind getRawTextStatus()
+    {
+        return textStatus;
+    }
+
+    /**
+     * Returns the real status of the item's contents as a string.
+     * @since 1.9
+     */
+    public String getRawTextStatusDescription()
+    {
+        return textStatus.toString();
+    }
+
+    /**
+     * Returns the adjusted status of the item's contents, as
+     * compatible with JavaHL 1.8 and older verions.
      * @return file status property enum of the "textual" component.
      */
     public Kind getTextStatus()
     {
-        return textStatus;
+        if (nodeStatus == Kind.modified || nodeStatus == Kind.conflicted)
+            return textStatus;
+        return nodeStatus;
     }
 
     /**
-     * Returns the status of the item as text.
+     * Returns the adjusted status of the item's contents as text.
      * @return english text
      */
     public String getTextStatusDescription()
     {
-        return textStatus.toString();
+        return getTextStatus().toString();
     }
 
     /**
-     * Returns the status of the properties (See Status Kind)
+     * Returns the status of the properties.
      * @return file status property enum of the "property" component.
      */
     public Kind getPropStatus()
@@ -337,17 +455,39 @@ public class Status implements java.io.S
     }
 
     /**
-     * Returns the status of the item in the repository (See StatusKind)
+     * Returns the status of the node in the repository.
+     * @since 1.9
+     */
+    public Kind getRepositoryNodeStatus()
+    {
+        return repositoryNodeStatus;
+    }
+
+    /**
+     * Returns the real status of the item's contents in the repository.
+     * @since 1.9
+     */
+    public Kind getRawRepositoryTextStatus()
+    {
+        return repositoryTextStatus;
+    }
+
+    /**
+     * Returns the adjusted status of the item's contents in the
+     * repository, as compatible with JavaHL 1.8 and older verions.
      * @return file status property enum of the "textual" component in the
      * repository.
      */
     public Kind getRepositoryTextStatus()
     {
-        return repositoryTextStatus;
+        if (repositoryNodeStatus == Kind.modified
+            || repositoryNodeStatus == Kind.conflicted)
+            return repositoryTextStatus;
+        return repositoryNodeStatus;
     }
 
     /**
-     * Returns test status of the properties in the repository (See StatusKind)
+     * Returns test status of the properties in the repository.
      * @return file status property enum of the "property" component im the
      * repository.
      */
@@ -440,7 +580,7 @@ public class Status implements java.io.S
      */
     public boolean isManaged()
     {
-        Kind status = getTextStatus();
+        Kind status = getNodeStatus();
         return (status != Status.Kind.unversioned &&
                 status != Status.Kind.none &&
                 status != Status.Kind.ignored);
@@ -452,7 +592,7 @@ public class Status implements java.io.S
      */
     public boolean hasRemote()
     {
-        return (isManaged() && getTextStatus() != Status.Kind.added);
+        return (isManaged() && !isAdded());
     }
 
     /**
@@ -461,7 +601,7 @@ public class Status implements java.io.S
      */
     public boolean isAdded()
     {
-        return getTextStatus() == Status.Kind.added;
+        return getNodeStatus() == Status.Kind.added;
     }
 
     /**
@@ -470,7 +610,7 @@ public class Status implements java.io.S
      */
     public boolean isDeleted()
     {
-        return getTextStatus() == Status.Kind.deleted;
+        return getNodeStatus() == Status.Kind.deleted;
     }
 
     /**
@@ -479,7 +619,7 @@ public class Status implements java.io.S
      */
     public boolean isMerged()
     {
-        return getTextStatus() == Status.Kind.merged;
+        return getNodeStatus() == Status.Kind.merged;
     }
 
     /**
@@ -489,7 +629,7 @@ public class Status implements java.io.S
      */
     public boolean isIgnored()
     {
-        return getTextStatus() == Status.Kind.ignored;
+        return getNodeStatus() == Status.Kind.ignored;
     }
 
     /**
@@ -601,6 +741,15 @@ public class Status implements java.io.S
     }
 
     /**
+     * Returns the inherent depth of the node, as recorded in the working copy.
+     * @since 1.9
+     */
+    public Depth getDepth()
+    {
+        return depth;
+    }
+
+    /**
      * Converts microseconds since the epoch to a Date object.
      *
      * @param micros Microseconds since the epoch.

Modified: subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java?rev=1576813&r1=1576812&r2=1576813&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java (original)
+++ subversion/trunk/subversion/bindings/javahl/tests/org/apache/subversion/javahl/BasicTests.java Wed Mar 12 16:39:49 2014
@@ -321,10 +321,8 @@ public class BasicTests extends SVNTests
         {
             Status st = statusCallback.getStatusArray()[0];
             if (st.isConflicted()
-                || st.getTextStatus() != Status.Kind.none
-                || st.getPropStatus() != Status.Kind.none
-                || st.getRepositoryTextStatus() != Status.Kind.none
-                || st.getRepositoryPropStatus() != Status.Kind.none)
+                || st.getNodeStatus() != Status.Kind.none
+                || st.getRepositoryNodeStatus() != Status.Kind.none)
                 fail("File foo.c should not return a status.");
         }