You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/12/16 06:35:41 UTC

svn commit: r1645847 - in /subversion/branches/fsx-id/subversion/libsvn_fs_x: dag.c dag.h tree.c

Author: stefan2
Date: Tue Dec 16 05:35:40 2014
New Revision: 1645847

URL: http://svn.apache.org/r1645847
Log:
On the fsx-id branch:  Add getters for node and copy id to the DAG node.
This allows us to replace all outside references to svn_fs_x__dag_get_id.

* subversion/libsvn_fs_x/dag.h
  (svn_fs_x__dag_get_node_id,
   svn_fs_x__dag_get_copy_id): Declare new internal API functions.
  (svn_fs_x__dag_related_node): Declare new convenience function.

* subversion/libsvn_fs_x/dag.c
  (svn_fs_x__dag_get_node_id,
   svn_fs_x__dag_get_copy_id,
   svn_fs_x__dag_related_node): Implement them.

* subversion/libsvn_fs_x/tree.c
  (get_copy_inheritance,
   make_path_mutable,
   x_node_relation,
   merge_changes,
   x_closest_copy): Use the new DAG API to replace calls to
                    svn_fs_x__dag_get_id.

Modified:
    subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c
    subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.h
    subversion/branches/fsx-id/subversion/libsvn_fs_x/tree.c

Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c?rev=1645847&r1=1645846&r2=1645847&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.c Tue Dec 16 05:35:40 2014
@@ -86,7 +86,6 @@ svn_node_kind_t svn_fs_x__dag_node_kind(
   return node->kind;
 }
 
-
 const svn_fs_id_t *
 svn_fs_x__dag_get_id(dag_node_t *node)
 {
@@ -101,6 +100,34 @@ svn_fs_x__dag_get_id(dag_node_t *node)
   return id;
 }
 
+/* Return the node revision ID of NODE.  The value returned is shared
+   with NODE, and will be deallocated when NODE is.  */
+svn_error_t *
+svn_fs_x__dag_get_node_id(svn_fs_x__id_part_t *node_id,
+                          dag_node_t *node)
+{
+  const svn_fs_id_t *id;
+
+  SVN_ERR(svn_fs_x__dag_get_fs_id(&id, node, node->node_pool));
+  *node_id = *svn_fs_x__id_node_id(id);
+
+  return SVN_NO_ERROR;
+}
+
+/* Return the node revision ID of NODE.  The value returned is shared
+   with NODE, and will be deallocated when NODE is.  */
+svn_error_t *
+svn_fs_x__dag_get_copy_id(svn_fs_x__id_part_t *copy_id,
+                          dag_node_t *node)
+{
+  const svn_fs_id_t *id;
+
+  SVN_ERR(svn_fs_x__dag_get_fs_id(&id, node, node->node_pool));
+  *copy_id = *svn_fs_x__id_copy_id(id);
+
+  return SVN_NO_ERROR;
+}
+
 
 const svn_fs_x__noderev_id_t *
 svn_fs_x__dag_get_noderev_id(const dag_node_t *node)
@@ -200,6 +227,22 @@ svn_fs_x__dag_get_fs_id(const svn_fs_id_
 
   return SVN_NO_ERROR;
 }
+
+/* Return the node ID of NODE.  The value returned is shared with NODE,
+   and will be deallocated when NODE is.  */
+svn_error_t *
+svn_fs_x__dag_related_node(svn_boolean_t *same,
+                           dag_node_t *lhs,
+                           dag_node_t *rhs)
+{
+  svn_fs_x__id_part_t lhs_node, rhs_node;
+
+  SVN_ERR(svn_fs_x__dag_get_node_id(&lhs_node, lhs));
+  SVN_ERR(svn_fs_x__dag_get_node_id(&rhs_node, rhs));
+  *same = svn_fs_x__id_part_eq(&lhs_node, &rhs_node);
+
+  return SVN_NO_ERROR;
+}
 
 
 svn_boolean_t svn_fs_x__dag_check_mutable(const dag_node_t *node)

Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.h?rev=1645847&r1=1645846&r2=1645847&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.h (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/dag.h Tue Dec 16 05:35:40 2014
@@ -121,6 +121,18 @@ const svn_fs_id_t *svn_fs_x__dag_get_id(
 const svn_fs_x__noderev_id_t *
 svn_fs_x__dag_get_noderev_id(const dag_node_t *node);
 
+/* Return the node ID of NODE.  The value returned is shared with NODE,
+   and will be deallocated when NODE is.  */
+svn_error_t *
+svn_fs_x__dag_get_node_id(svn_fs_x__id_part_t *node_id,
+                          dag_node_t *node);
+
+/* Return the copy ID of NODE.  The value returned is shared with NODE,
+   and will be deallocated when NODE is.  */
+svn_error_t *
+svn_fs_x__dag_get_copy_id(svn_fs_x__id_part_t *copy_id,
+                          dag_node_t *node);
+
 /* Return the FS API node revision ID of NODE in *ID, allocated in
    RESULT_POOL. */
 svn_error_t *
@@ -128,6 +140,12 @@ svn_fs_x__dag_get_fs_id(const svn_fs_id_
                         dag_node_t *node,
                         apr_pool_t *result_pool);
 
+/* Set *SAME to TRUE, if nodes LHS and RHS have the same node ID. */
+svn_error_t *
+svn_fs_x__dag_related_node(svn_boolean_t *same,
+                           dag_node_t *lhs,
+                           dag_node_t *rhs);
+
 /* Return the created path of NODE.  The value returned is shared
    with NODE, and will be deallocated when NODE is.  */
 const char *svn_fs_x__dag_get_created_path(dag_node_t *node);

Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/tree.c?rev=1645847&r1=1645846&r2=1645847&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/tree.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/tree.c Tue Dec 16 05:35:40 2014
@@ -815,8 +815,8 @@ get_copy_inheritance(copy_id_inherit_t *
                      parent_path_t *child,
                      apr_pool_t *pool)
 {
-  const svn_fs_id_t *child_id, *parent_id, *copyroot_id;
-  const svn_fs_x__id_part_t *child_copy_id, *parent_copy_id;
+  svn_fs_x__id_part_t child_copy_id, parent_copy_id;
+  svn_boolean_t related;
   const char *id_path = NULL;
   svn_fs_root_t *copyroot_root;
   dag_node_t *copyroot_node;
@@ -826,13 +826,11 @@ get_copy_inheritance(copy_id_inherit_t *
   SVN_ERR_ASSERT(child && child->parent);
 
   /* Initialize some convenience variables. */
-  child_id = svn_fs_x__dag_get_id(child->node);
-  parent_id = svn_fs_x__dag_get_id(child->parent->node);
-  child_copy_id = svn_fs_x__id_copy_id(child_id);
-  parent_copy_id = svn_fs_x__id_copy_id(parent_id);
+  SVN_ERR(svn_fs_x__dag_get_copy_id(&child_copy_id, child->node));
+  SVN_ERR(svn_fs_x__dag_get_copy_id(&parent_copy_id, child->parent->node));
 
   /* If this child is already mutable, we have nothing to do. */
-  if (svn_fs_x__id_is_txn(child_id))
+  if (svn_fs_x__dag_check_mutable(child->node))
     {
       *inherit_p = copy_id_inherit_self;
       *copy_src_path = NULL;
@@ -846,14 +844,14 @@ get_copy_inheritance(copy_id_inherit_t *
 
   /* Special case: if the child's copy ID is '0', use the parent's
      copy ID. */
-  if (svn_fs_x__id_part_is_root(child_copy_id))
+  if (svn_fs_x__id_part_is_root(&child_copy_id))
     return SVN_NO_ERROR;
 
   /* Compare the copy IDs of the child and its parent.  If they are
      the same, then the child is already on the same branch as the
      parent, and should use the same mutability copy ID that the
      parent will use. */
-  if (svn_fs_x__id_part_eq(child_copy_id, parent_copy_id))
+  if (svn_fs_x__id_part_eq(&child_copy_id, &parent_copy_id))
     return SVN_NO_ERROR;
 
   /* If the child is on the same branch that the parent is on, the
@@ -864,12 +862,12 @@ get_copy_inheritance(copy_id_inherit_t *
      or if it is a branch point that we are accessing via its original
      copy destination path. */
   SVN_ERR(svn_fs_x__dag_get_copyroot(&copyroot_rev, &copyroot_path,
-                                      child->node));
+                                     child->node));
   SVN_ERR(svn_fs_x__revision_root(&copyroot_root, fs, copyroot_rev, pool));
   SVN_ERR(get_dag(&copyroot_node, copyroot_root, copyroot_path, FALSE, pool));
-  copyroot_id = svn_fs_x__dag_get_id(copyroot_node);
 
-  if (svn_fs_x__id_compare(copyroot_id, child_id) == svn_fs_node_unrelated)
+  SVN_ERR(svn_fs_x__dag_related_node(&related, copyroot_node, child->node));
+  if (!related)
     return SVN_NO_ERROR;
 
   /* Determine if we are looking at the child via its original path or
@@ -1237,7 +1235,6 @@ make_path_mutable(svn_fs_root_t *root,
   /* Are we trying to clone the root, or somebody's child node?  */
   if (parent_path->parent)
     {
-      const svn_fs_id_t *parent_id, *child_id, *copyroot_id;
       svn_fs_x__id_part_t copy_id = { SVN_INVALID_REVNUM, 0 };
       svn_fs_x__id_part_t *copy_id_ptr = &copy_id;
       copy_id_inherit_t inherit = parent_path->copy_inherit;
@@ -1246,6 +1243,7 @@ make_path_mutable(svn_fs_root_t *root,
       svn_boolean_t is_parent_copyroot = FALSE;
       svn_fs_root_t *copyroot_root;
       dag_node_t *copyroot_node;
+      svn_boolean_t related;
 
       /* We're trying to clone somebody's child.  Make sure our parent
          is mutable.  */
@@ -1255,8 +1253,8 @@ make_path_mutable(svn_fs_root_t *root,
       switch (inherit)
         {
         case copy_id_inherit_parent:
-          parent_id = svn_fs_x__dag_get_id(parent_path->parent->node);
-          copy_id = *svn_fs_x__id_copy_id(parent_id);
+          SVN_ERR(svn_fs_x__dag_get_copy_id(&copy_id,
+                                            parent_path->parent->node));
           break;
 
         case copy_id_inherit_new:
@@ -1282,10 +1280,9 @@ make_path_mutable(svn_fs_root_t *root,
       SVN_ERR(get_dag(&copyroot_node, copyroot_root, copyroot_path,
                       FALSE, pool));
 
-      child_id = svn_fs_x__dag_get_id(parent_path->node);
-      copyroot_id = svn_fs_x__dag_get_id(copyroot_node);
-      if (!svn_fs_x__id_part_eq(svn_fs_x__id_node_id(child_id),
-                                svn_fs_x__id_node_id(copyroot_id)))
+      SVN_ERR(svn_fs_x__dag_related_node(&related, copyroot_node,
+                                         parent_path->node));
+      if (!related)
         is_parent_copyroot = TRUE;
 
       /* Now make this node mutable.  */
@@ -1438,7 +1435,6 @@ x_node_relation(svn_fs_node_relation_t *
                 apr_pool_t *pool)
 {
   dag_node_t *node;
-  const svn_fs_id_t *id;
   svn_fs_x__id_part_t noderev_id_a, noderev_id_b, node_id_a, node_id_b;
 
   /* Root paths are a common special case. */
@@ -1475,14 +1471,12 @@ x_node_relation(svn_fs_node_relation_t *
   /* We checked for all separations between ID spaces (repos, txn).
    * Now, we can simply test for the ID values themselves. */
   SVN_ERR(get_dag(&node, root_a, path_a, FALSE, pool));
-  id = svn_fs_x__dag_get_id(node);
-  noderev_id_a = *svn_fs_x__id_noderev_id(id);
-  node_id_a = *svn_fs_x__id_node_id(id);
+  noderev_id_a = *svn_fs_x__dag_get_noderev_id(node);
+  SVN_ERR(svn_fs_x__dag_get_node_id(&node_id_a, node));
 
   SVN_ERR(get_dag(&node, root_b, path_b, FALSE, pool));
-  id = svn_fs_x__dag_get_id(node);
-  noderev_id_b = *svn_fs_x__id_noderev_id(id);
-  node_id_b = *svn_fs_x__id_node_id(id);
+  noderev_id_b = *svn_fs_x__dag_get_noderev_id(node);
+  SVN_ERR(svn_fs_x__dag_get_node_id(&node_id_b, node));
 
   if (svn_fs_x__id_part_eq(&noderev_id_a, &noderev_id_b))
     *relation = svn_fs_node_same;
@@ -2183,6 +2177,7 @@ merge_changes(dag_node_t *ancestor_node,
   dag_node_t *txn_root_node;
   svn_fs_t *fs = txn->fs;
   svn_fs_x__txn_id_t txn_id = svn_fs_x__txn_get_id(txn);
+  svn_boolean_t related;
   
   SVN_ERR(svn_fs_x__dag_txn_root(&txn_root_node, fs, txn_id, pool));
 
@@ -2192,8 +2187,8 @@ merge_changes(dag_node_t *ancestor_node,
                                           txn_id, pool));
     }
 
-  if (svn_fs_x__id_eq(svn_fs_x__dag_get_id(ancestor_node),
-                      svn_fs_x__dag_get_id(txn_root_node)))
+  SVN_ERR(svn_fs_x__dag_related_node(&related, ancestor_node, txn_root_node));
+  if (!related)
     {
       /* If no changes have been made in TXN since its current base,
          then it can't conflict with any changes since that base.
@@ -3398,6 +3393,7 @@ svn_error_t *x_closest_copy(svn_fs_root_
   const char *copy_dst_path;
   svn_fs_root_t *copy_dst_root;
   dag_node_t *copy_dst_node;
+  svn_boolean_t related;
 
   /* Initialize return values. */
   *root_p = NULL;
@@ -3424,8 +3420,9 @@ svn_error_t *x_closest_copy(svn_fs_root_
     return SVN_NO_ERROR;
 
   copy_dst_node = copy_dst_parent_path->node;
-  if (! svn_fs_x__id_check_related(svn_fs_x__dag_get_id(copy_dst_node),
-                                   svn_fs_x__dag_get_id(parent_path->node)))
+  SVN_ERR(svn_fs_x__dag_related_node(&related, copy_dst_node,
+                                     parent_path->node));
+  if (!related)
     return SVN_NO_ERROR;
 
   /* One final check must be done here.  If you copy a directory and