FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/transaction.c
/* Verify that the user registered with FS has all the locks necessary to
   permit all the changes associated with TXN_NAME.
   The FS write lock is assumed to be held by the caller. */
Verify that the user registered with FS has all the locks necessary to
permit all the changes associated with TXN_NAME.
The FS write lock is assumed to be held by the caller.
Verify that the user registered with FS has all the locks necessary to permit all the changes associated with TXN_NAME . The FS write lock is assumed to be held by the caller .
static svn_error_t *
verify_locks(svn_fs_t *fs,
             const svn_fs_fs__id_part_t *txn_id,
             apr_hash_t *changed_paths,
             apr_pool_t *pool)
{
  apr_pool_t *iterpool;
  apr_array_header_t *changed_paths_sorted;
  svn_stringbuf_t *last_recursed = NULL;
  int i;
  changed_paths_sorted = svn_sort__hash(changed_paths,
                                        svn_sort_compare_items_as_paths,
                                        pool);
  iterpool = svn_pool_create(pool);
  for (i = 0; i < changed_paths_sorted->nelts; i++)
    {
      const svn_sort__item_t *item;
      const char *path;
      svn_fs_path_change2_t *change;
      svn_boolean_t recurse = TRUE;
      svn_pool_clear(iterpool);
      item = &APR_ARRAY_IDX(changed_paths_sorted, i, svn_sort__item_t);
      path = item->key;
      change = item->value;
      if (last_recursed
          && svn_fspath__skip_ancestor(last_recursed->data, path))
        continue;
      if (change->change_kind == svn_fs_path_change_modify)
        recurse = FALSE;
      SVN_ERR(svn_fs_fs__allow_locked_operation(path, fs, recurse, TRUE,
                                                iterpool));
      if (recurse)
        {
          if (! last_recursed)
            last_recursed = svn_stringbuf_create(path, pool);
          else
            svn_stringbuf_set(last_recursed, path);
        }
    }
  svn_pool_destroy(iterpool);
  return SVN_NO_ERROR;
}
static svn_error_t * verify_locks ( svn_fs_t * fs , const svn_fs_fs__id_part_t * txn_id , apr_hash_t * changed_paths , apr_pool_t * pool ) { apr_pool_t * iterpool ; apr_array_header_t * changed_paths_sorted ; svn_stringbuf_t * last_recursed = NULL ; int i ; changed_paths_sorted = svn_sort__hash ( changed_paths , svn_sort_compare_items_as_paths , pool ) ; iterpool = svn_pool_create ( pool ) ; for ( i = 0 ; i < changed_paths_sorted -> nelts ; i ++ ) { const svn_sort__item_t * item ; const char * path ; svn_fs_path_change2_t * change ; svn_boolean_t recurse = TRUE ; svn_pool_clear ( iterpool ) ; item = & APR_ARRAY_IDX ( changed_paths_sorted , i , svn_sort__item_t ) ; path = item -> key ; change = item -> value ; if ( last_recursed && svn_fspath__skip_ancestor ( last_recursed -> data , path ) ) continue ; if ( change -> change_kind == svn_fs_path_change_modify ) recurse = FALSE ; SVN_ERR ( svn_fs_fs__allow_locked_operation ( path , fs , recurse , TRUE , iterpool ) ) ; if ( recurse ) { if ( ! last_recursed ) last_recursed = svn_stringbuf_create ( path , pool ) ; else svn_stringbuf_set ( last_recursed , path ) ; } } svn_pool_destroy ( iterpool ) ; return SVN_NO_ERROR ; }
Verify that the user registered with FS has all the locks necessary to
permit all the changes associated with TXN_NAME.
Verify that the user registered with FS has all the locks necessary to permit all the changes associated with TXN_NAME .
/* Make an array of the changed paths, and sort them depth-first-ily.  */ /* Now, traverse the array of changed paths, verify locks.  Note
     that if we need to do a recursive verification a path, we'll skip
     over children of that path when we get to them. */ /* Fetch the change associated with our path.  */ /* If this path has already been verified as part of a recursive
         check of one of its parents, no need to do it again.  */ /* What does it mean to succeed at lock verification for a given
         path?  For an existing file or directory getting modified
         (text, props), it means we hold the lock on the file or
         directory.  For paths being added or removed, we need to hold
         the locks for that path and any children of that path.

         WHEW!  We have no reliable way to determine the node kind
         of deleted items, but fortunately we are going to do a
         recursive check on deleted paths regardless of their kind.  */ /* If we just did a recursive check, remember the path we
         checked (so children can be skipped).  */