FreeBSD/contrib/subversion/subversion/libsvn_fs_x/tree.c
/* Change, add, or delete a node's property value.  The affected node
   is PATH under ROOT, the property value to modify is NAME, and VALUE
   points to either a string value to set the new contents to, or NULL
   if the property should be deleted.  Perform temporary allocations
   in SCRATCH_POOL. */
Change, add, or delete a node's property value.  The affected node
is PATH under ROOT, the property value to modify is NAME, and VALUE
points to either a string value to set the new contents to, or NULL
if the property should be deleted.  Perform temporary allocations
in SCRATCH_POOL.
Change add or delete a node ' s property value . The affected node is PATH under ROOT the property value to modify is NAME and VALUE points to either a string value to set the new contents to or NULL if the property should be deleted . Perform temporary allocations in SCRATCH_POOL .
static svn_error_t *
x_change_node_prop(svn_fs_root_t *root,
                   const char *path,
                   const char *name,
                   const svn_string_t *value,
                   apr_pool_t *scratch_pool)
{
  parent_path_t *parent_path;
  apr_hash_t *proplist;
  svn_fs_x__txn_id_t txn_id;
  svn_boolean_t mergeinfo_mod = FALSE;
  apr_pool_t *subpool = svn_pool_create(scratch_pool);
  if (! root->is_txn_root)
    return SVN_FS__NOT_TXN(root);
  txn_id = root_txn_id(root);
  path = svn_fs__canonicalize_abspath(path, subpool);
  SVN_ERR(open_path(&parent_path, root, path, 0, TRUE, subpool));
  if (root->txn_flags & SVN_FS_TXN_CHECK_LOCKS)
    SVN_ERR(svn_fs_x__allow_locked_operation(path, root->fs, FALSE, FALSE,
                                             subpool));
  SVN_ERR(make_path_mutable(root, parent_path, path, subpool, subpool));
  SVN_ERR(svn_fs_x__dag_get_proplist(&proplist, parent_path->node, subpool,
                                     subpool));
  if ((! proplist) && (! value))
    return SVN_NO_ERROR;
  if (! proplist)
    proplist = apr_hash_make(subpool);
  if (strcmp(name, SVN_PROP_MERGEINFO) == 0)
    {
      apr_int64_t increment = 0;
      svn_boolean_t had_mergeinfo;
      SVN_ERR(svn_fs_x__dag_has_mergeinfo(&had_mergeinfo, parent_path->node));
      if (value && !had_mergeinfo)
        increment = 1;
      else if (!value && had_mergeinfo)
        increment = -1;
      if (increment != 0)
        {
          SVN_ERR(increment_mergeinfo_up_tree(parent_path, increment, subpool));
          SVN_ERR(svn_fs_x__dag_set_has_mergeinfo(parent_path->node,
                                                  (value != NULL), subpool));
        }
      mergeinfo_mod = TRUE;
    }
  svn_hash_sets(proplist, name, value);
  SVN_ERR(svn_fs_x__dag_set_proplist(parent_path->node, proplist,
                                     subpool));
  SVN_ERR(add_change(root->fs, txn_id, path,
                     svn_fs_x__dag_get_id(parent_path->node),
                     svn_fs_path_change_modify, FALSE, TRUE, mergeinfo_mod,
                     svn_fs_x__dag_node_kind(parent_path->node),
                     SVN_INVALID_REVNUM, NULL, subpool));
  svn_pool_destroy(subpool);
  return SVN_NO_ERROR;
}
static svn_error_t * x_change_node_prop ( svn_fs_root_t * root , const char * path , const char * name , const svn_string_t * value , apr_pool_t * scratch_pool ) { parent_path_t * parent_path ; apr_hash_t * proplist ; svn_fs_x__txn_id_t txn_id ; svn_boolean_t mergeinfo_mod = FALSE ; apr_pool_t * subpool = svn_pool_create ( scratch_pool ) ; if ( ! root -> is_txn_root ) return SVN_FS__NOT_TXN ( root ) ; txn_id = root_txn_id ( root ) ; path = svn_fs__canonicalize_abspath ( path , subpool ) ; SVN_ERR ( open_path ( & parent_path , root , path , 0 , TRUE , subpool ) ) ; if ( root -> txn_flags & SVN_FS_TXN_CHECK_LOCKS ) SVN_ERR ( svn_fs_x__allow_locked_operation ( path , root -> fs , FALSE , FALSE , subpool ) ) ; SVN_ERR ( make_path_mutable ( root , parent_path , path , subpool , subpool ) ) ; SVN_ERR ( svn_fs_x__dag_get_proplist ( & proplist , parent_path -> node , subpool , subpool ) ) ; if ( ( ! proplist ) && ( ! value ) ) return SVN_NO_ERROR ; if ( ! proplist ) proplist = apr_hash_make ( subpool ) ; if ( strcmp ( name , SVN_PROP_MERGEINFO ) == 0 ) { apr_int64_t increment = 0 ; svn_boolean_t had_mergeinfo ; SVN_ERR ( svn_fs_x__dag_has_mergeinfo ( & had_mergeinfo , parent_path -> node ) ) ; if ( value && ! had_mergeinfo ) increment = 1 ; else if ( ! value && had_mergeinfo ) increment = -1 ; if ( increment != 0 ) { SVN_ERR ( increment_mergeinfo_up_tree ( parent_path , increment , subpool ) ) ; SVN_ERR ( svn_fs_x__dag_set_has_mergeinfo ( parent_path -> node , ( value != NULL ) , subpool ) ) ; } mergeinfo_mod = TRUE ; } svn_hash_sets ( proplist , name , value ) ; SVN_ERR ( svn_fs_x__dag_set_proplist ( parent_path -> node , proplist , subpool ) ) ; SVN_ERR ( add_change ( root -> fs , txn_id , path , svn_fs_x__dag_get_id ( parent_path -> node ) , svn_fs_path_change_modify , FALSE , TRUE , mergeinfo_mod , svn_fs_x__dag_node_kind ( parent_path -> node ) , SVN_INVALID_REVNUM , NULL , subpool ) ) ; svn_pool_destroy ( subpool ) ; return SVN_NO_ERROR ; }
Change, add, or delete a node's property value.
Change add or delete a node ' s property value .
/* Check (non-recursively) to see if path is locked; if so, check
     that we can use it. */ /* If there's no proplist, but we're just deleting a property, exit now. */ /* Now, if there's no proplist, we know we need to make one. */ /* Set the property. */ /* Overwrite the node's proplist. */ /* Make a record of this modification in the changes table. */