FreeBSD/contrib/subversion/subversion/libsvn_fs_x/tree.c
/* Make the node referred to by PARENT_PATH mutable, if it isn't already,
   allocating from RESULT_POOL.  ROOT must be the root from which
   PARENT_PATH descends.  Clone any parent directories as needed.
   Adjust the dag nodes in PARENT_PATH to refer to the clones.  Use
   ERROR_PATH in error messages.  Use SCRATCH_POOL for temporaries. */
Make the node referred to by PARENT_PATH mutable, if it isn't already,
allocating from RESULT_POOL.  ROOT must be the root from which
PARENT_PATH descends.  Clone any parent directories as needed.
Adjust the dag nodes in PARENT_PATH to refer to the clones.  Use
ERROR_PATH in error messages.  Use SCRATCH_POOL for temporaries.
Make the node referred to by PARENT_PATH mutable if it isn ' t already allocating from RESULT_POOL . ROOT must be the root from which PARENT_PATH descends . Clone any parent directories as needed . Adjust the dag nodes in PARENT_PATH to refer to the clones . Use ERROR_PATH in error messages . Use SCRATCH_POOL for temporaries .
static svn_error_t *
make_path_mutable(svn_fs_root_t *root,
                  parent_path_t *parent_path,
                  const char *error_path,
                  apr_pool_t *result_pool,
                  apr_pool_t *scratch_pool)
{
  dag_node_t *clone;
  svn_fs_x__txn_id_t txn_id = root_txn_id(root);
  if (svn_fs_x__dag_check_mutable(parent_path->node))
    return SVN_NO_ERROR;
  if (parent_path->parent)
    {
      svn_fs_x__id_t copy_id = { SVN_INVALID_REVNUM, 0 };
      svn_fs_x__id_t *copy_id_ptr = &copy_id;
      copy_id_inherit_t inherit = parent_path->copy_inherit;
      const char *clone_path, *copyroot_path;
      svn_revnum_t copyroot_rev;
      svn_boolean_t is_parent_copyroot = FALSE;
      svn_fs_root_t *copyroot_root;
      dag_node_t *copyroot_node;
      svn_boolean_t related;
      SVN_ERR(make_path_mutable(root, parent_path->parent,
                                error_path, result_pool, scratch_pool));
      switch (inherit)
        {
        case copy_id_inherit_parent:
          SVN_ERR(svn_fs_x__dag_get_copy_id(&copy_id,
                                            parent_path->parent->node));
          break;
        case copy_id_inherit_new:
          SVN_ERR(svn_fs_x__reserve_copy_id(&copy_id, root->fs, txn_id,
                                            scratch_pool));
          break;
        case copy_id_inherit_self:
          copy_id_ptr = NULL;
          break;
        case copy_id_inherit_unknown:
        default:
          SVN_ERR_MALFUNCTION(); 
        }
      SVN_ERR(svn_fs_x__dag_get_copyroot(&copyroot_rev, &copyroot_path,
                                          parent_path->node));
      SVN_ERR(svn_fs_x__revision_root(&copyroot_root, root->fs,
                                      copyroot_rev, scratch_pool));
      SVN_ERR(get_dag(&copyroot_node, copyroot_root, copyroot_path,
                      result_pool));
      SVN_ERR(svn_fs_x__dag_related_node(&related, copyroot_node,
                                         parent_path->node));
      if (!related)
        is_parent_copyroot = TRUE;
      clone_path = parent_path_path(parent_path->parent, scratch_pool);
      SVN_ERR(svn_fs_x__dag_clone_child(&clone,
                                        parent_path->parent->node,
                                        clone_path,
                                        parent_path->entry,
                                        copy_id_ptr, txn_id,
                                        is_parent_copyroot,
                                        result_pool,
                                        scratch_pool));
      SVN_ERR(dag_node_cache_set(root,
                                 parent_path_path(parent_path, scratch_pool),
                                 clone, scratch_pool));
    }
  else
    {
      SVN_ERR(mutable_root_node(&clone, root, error_path, result_pool,
                                scratch_pool));
    }
  parent_path->node = clone;
  return SVN_NO_ERROR;
}
static svn_error_t * make_path_mutable ( svn_fs_root_t * root , parent_path_t * parent_path , const char * error_path , apr_pool_t * result_pool , apr_pool_t * scratch_pool ) { dag_node_t * clone ; svn_fs_x__txn_id_t txn_id = root_txn_id ( root ) ; if ( svn_fs_x__dag_check_mutable ( parent_path -> node ) ) return SVN_NO_ERROR ; if ( parent_path -> parent ) { svn_fs_x__id_t copy_id = { SVN_INVALID_REVNUM , 0 } ; svn_fs_x__id_t * copy_id_ptr = & copy_id ; copy_id_inherit_t inherit = parent_path -> copy_inherit ; const char * clone_path , * copyroot_path ; svn_revnum_t copyroot_rev ; svn_boolean_t is_parent_copyroot = FALSE ; svn_fs_root_t * copyroot_root ; dag_node_t * copyroot_node ; svn_boolean_t related ; SVN_ERR ( make_path_mutable ( root , parent_path -> parent , error_path , result_pool , scratch_pool ) ) ; switch ( inherit ) { case copy_id_inherit_parent : SVN_ERR ( svn_fs_x__dag_get_copy_id ( & copy_id , parent_path -> parent -> node ) ) ; break ; case copy_id_inherit_new : SVN_ERR ( svn_fs_x__reserve_copy_id ( & copy_id , root -> fs , txn_id , scratch_pool ) ) ; break ; case copy_id_inherit_self : copy_id_ptr = NULL ; break ; case copy_id_inherit_unknown : default : SVN_ERR_MALFUNCTION ( ) ; } SVN_ERR ( svn_fs_x__dag_get_copyroot ( & copyroot_rev , & copyroot_path , parent_path -> node ) ) ; SVN_ERR ( svn_fs_x__revision_root ( & copyroot_root , root -> fs , copyroot_rev , scratch_pool ) ) ; SVN_ERR ( get_dag ( & copyroot_node , copyroot_root , copyroot_path , result_pool ) ) ; SVN_ERR ( svn_fs_x__dag_related_node ( & related , copyroot_node , parent_path -> node ) ) ; if ( ! related ) is_parent_copyroot = TRUE ; clone_path = parent_path_path ( parent_path -> parent , scratch_pool ) ; SVN_ERR ( svn_fs_x__dag_clone_child ( & clone , parent_path -> parent -> node , clone_path , parent_path -> entry , copy_id_ptr , txn_id , is_parent_copyroot , result_pool , scratch_pool ) ) ; SVN_ERR ( dag_node_cache_set ( root , parent_path_path ( parent_path , scratch_pool ) , clone , scratch_pool ) ) ; } else { SVN_ERR ( mutable_root_node ( & clone , root , error_path , result_pool , scratch_pool ) ) ; } parent_path -> node = clone ; return SVN_NO_ERROR ; }
Make the node referred to by PARENT_PATH mutable, if it isn't already,
allocating from RESULT_POOL.
Make the node referred to by PARENT_PATH mutable if it isn ' t already allocating from RESULT_POOL .
/* Is the node mutable already?  */ /* Are we trying to clone the root, or somebody's child node?  */ /* We're trying to clone somebody's child.  Make sure our parent
         is mutable.  */ /* uh-oh -- somebody didn't calculate copy-ID
                      inheritance data. */ /* Determine what copyroot our new child node should use. */ /* Now make this node mutable.  */ /* Update the path cache. */ /* We're trying to clone the root directory.  */ /* Update the PARENT_PATH link to refer to the clone.  */