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 2010/02/03 23:16:01 UTC
svn commit: r906267 - in /subversion/trunk/subversion/libsvn_client: add.c
externals.c revert.c
Author: stsp
Date: Wed Feb 3 22:16:00 2010
New Revision: 906267
URL: http://svn.apache.org/viewvc?rev=906267&view=rev
Log:
In libsvn_client, switch most current callers of svn_wc__acquire_write_lock()
and svn_wc__release_write_lock() to just svn_wc__call_with_write_lock().
Leaving one caller in libsvn_client/externals.c for later.
* subversion/libsvn_client/add.c
(add_with_write_lock_baton): New.
(add): Move all arguments into above baton to be passed in via
svn_wc__call_with_write_lock().
(svn_client_add4): Call add() via svn_wc__call_with_write_lock().
* subversion/libsvn_client/externals.c
(relegate_dir_external_with_write_lock_baton): New.
(relegate_dir_external): Move all arguments into above baton to be passed
in via svn_wc__call_with_write_lock(). Convert the PATH argument to
an absolute LOCAL_ABSPATH.
(switch_dir_external): Call relegate_dir_external() via
svn_wc__call_with_write_lock().
* subversion/libsvn_client/revert.c
(revert_with_write_lock_baton): New.
(revert): Move all arguments into above baton to be passed in via
svn_wc__call_with_write_lock(). Convert the PATH argument to
an absolute LOCAL_ABSPATH.
(svn_client_revert2): Call revert() via svn_wc__call_with_write_lock().
Modified:
subversion/trunk/subversion/libsvn_client/add.c
subversion/trunk/subversion/libsvn_client/externals.c
subversion/trunk/subversion/libsvn_client/revert.c
Modified: subversion/trunk/subversion/libsvn_client/add.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/add.c?rev=906267&r1=906266&r2=906267&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/add.c (original)
+++ subversion/trunk/subversion/libsvn_client/add.c Wed Feb 3 22:16:00 2010
@@ -487,39 +487,43 @@
}
-/* The main logic of the public svn_client_add4; the only difference
- is that this function uses an existing access baton.
- (svn_client_add4 just generates an access baton and calls this func.) */
+struct add_with_write_lock_baton {
+ const char *local_abspath;
+ svn_depth_t depth;
+ svn_boolean_t force;
+ svn_boolean_t no_ignore;
+ svn_client_ctx_t *ctx;
+};
+
+/* The main logic of the public svn_client_add4. */
static svn_error_t *
-add(const char *local_abspath,
- svn_depth_t depth,
- svn_boolean_t force,
- svn_boolean_t no_ignore,
- svn_client_ctx_t *ctx,
- apr_pool_t *pool)
+add(void *baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
{
svn_node_kind_t kind;
svn_error_t *err;
+ struct add_with_write_lock_baton *b = baton;
- SVN_ERR(svn_io_check_path(local_abspath, &kind, pool));
+ SVN_ERR(svn_io_check_path(b->local_abspath, &kind, scratch_pool));
if (kind == svn_node_dir)
{
/* We use add_dir_recursive for all directory targets
and pass depth along no matter what it is, so that the
target's depth will be set correctly. */
- err = add_dir_recursive(local_abspath, depth,
- force, no_ignore, ctx, pool);
+ err = add_dir_recursive(b->local_abspath, b->depth,
+ b->force, b->no_ignore, b->ctx,
+ scratch_pool);
}
else if (kind == svn_node_file)
- err = add_file(local_abspath, ctx, pool);
+ err = add_file(b->local_abspath, b->ctx, scratch_pool);
else
- err = svn_wc_add4(ctx->wc_ctx, local_abspath, depth, NULL,
+ err = svn_wc_add4(b->ctx->wc_ctx, b->local_abspath, b->depth, NULL,
SVN_INVALID_REVNUM,
- ctx->cancel_func, ctx->cancel_baton,
- ctx->notify_func2, ctx->notify_baton2, pool);
+ b->ctx->cancel_func, b->ctx->cancel_baton,
+ b->ctx->notify_func2, b->ctx->notify_baton2,
+ scratch_pool);
/* Ignore SVN_ERR_ENTRY_EXISTS when FORCE is set. */
- if (err && err->apr_err == SVN_ERR_ENTRY_EXISTS && force)
+ if (err && err->apr_err == SVN_ERR_ENTRY_EXISTS && b->force)
{
svn_error_clear(err);
err = SVN_NO_ERROR;
@@ -579,9 +583,9 @@
svn_client_ctx_t *ctx,
apr_pool_t *pool)
{
- svn_error_t *err;
const char *parent_abspath;
const char *local_abspath;
+ struct add_with_write_lock_baton baton;
SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
@@ -606,17 +610,14 @@
svn_pool_destroy(subpool);
}
- SVN_ERR(svn_wc__acquire_write_lock(NULL, ctx->wc_ctx, parent_abspath,
- pool, pool));
-
- err = add(local_abspath, depth, force, no_ignore, ctx, pool);
-
- /* ### Currently we rely on the fact that this releases all our write locks
- ### recursively. */
- return svn_error_return(
- svn_error_compose_create(
- err,
- svn_wc__release_write_lock(ctx->wc_ctx, parent_abspath, pool)));
+ baton.local_abspath = local_abspath;
+ baton.depth = depth;
+ baton.force = force;
+ baton.no_ignore = no_ignore;
+ baton.ctx = ctx;
+ SVN_ERR(svn_wc__call_with_write_lock(add, &baton, ctx->wc_ctx,
+ parent_abspath, pool, pool));
+ return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_client/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/externals.c?rev=906267&r1=906266&r2=906267&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/externals.c (original)
+++ subversion/trunk/subversion/libsvn_client/externals.c Wed Feb 3 22:16:00 2010
@@ -80,41 +80,37 @@
};
-/* Remove the directory at PATH from revision control, and do the same
- * to any revision controlled directories underneath PATH (including
- * directories not referred to by parent svn administrative areas);
- * then if PATH is empty afterwards, remove it, else rename it to a
+struct relegate_dir_external_with_write_lock_baton {
+ const char *local_abspath;
+ svn_wc_context_t *wc_ctx;
+ svn_cancel_func_t cancel_func;
+ void *cancel_baton;
+};
+
+/* Note: All arguments are in the baton above.
+ *
+ * Remove the directory at LOCAL_ABSPATH from revision control, and do the
+ * same to any revision controlled directories underneath LOCAL_ABSPATH
+ * (including directories not referred to by parent svn administrative areas);
+ * then if LOCAL_ABSPATH is empty afterwards, remove it, else rename it to a
* unique name in the same parent directory.
*
* Pass CANCEL_FUNC, CANCEL_BATON to svn_wc_remove_from_revision_control.
*
- * Use POOL for all temporary allocation.
- *
- * Note: this function is not passed a svn_wc_adm_access_t. Instead,
- * it separately opens the object being deleted, so that if there is a
- * lock on that object, the object cannot be deleted.
+ * Use SCRATCH_POOL for all temporary allocation.
*/
static svn_error_t *
-relegate_dir_external(const char *path,
- svn_wc_context_t *wc_ctx,
- svn_cancel_func_t cancel_func,
- void *cancel_baton,
- apr_pool_t *pool)
+relegate_dir_external(void *baton,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
+ struct relegate_dir_external_with_write_lock_baton *b = baton;
svn_error_t *err = SVN_NO_ERROR;
- const char *local_abspath;
- SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
- SVN_ERR(svn_wc__acquire_write_lock(NULL, wc_ctx, local_abspath, NULL, pool));
- err = svn_wc_remove_from_revision_control2(wc_ctx, local_abspath,
+ err = svn_wc_remove_from_revision_control2(b->wc_ctx, b->local_abspath,
TRUE, FALSE,
- cancel_func, cancel_baton,
- pool);
-
- /* ### Ugly. Unlock only if not going to return an error. Revisit */
- if (!err || err->apr_err == SVN_ERR_WC_LEFT_LOCAL_MOD)
- SVN_ERR(svn_wc__release_write_lock(wc_ctx, local_abspath, pool));
-
+ b->cancel_func, b->cancel_baton,
+ scratch_pool);
if (err && (err->apr_err == SVN_ERR_WC_LEFT_LOCAL_MOD))
{
const char *parent_dir;
@@ -124,12 +120,13 @@
svn_error_clear(err);
err = SVN_NO_ERROR;
- svn_dirent_split(path, &parent_dir, &dirname, pool);
+ svn_dirent_split(b->local_abspath, &parent_dir, &dirname, scratch_pool);
/* Reserve the new dir name. */
SVN_ERR(svn_io_open_uniquely_named(NULL, &new_path,
parent_dir, dirname, ".OLD",
- svn_io_file_del_none, pool, pool));
+ svn_io_file_del_none,
+ scratch_pool, scratch_pool));
/* Sigh... We must fall ever so slightly from grace.
@@ -150,10 +147,10 @@
no big deal.
*/
/* Do our best, but no biggy if it fails. The rename will fail. */
- svn_error_clear(svn_io_remove_file2(new_path, TRUE, pool));
+ svn_error_clear(svn_io_remove_file2(new_path, TRUE, scratch_pool));
/* Rename. */
- SVN_ERR(svn_io_file_rename(path, new_path, pool));
+ SVN_ERR(svn_io_file_rename(b->local_abspath, new_path, scratch_pool));
}
return svn_error_return(err);
@@ -258,12 +255,21 @@
svn_pool_destroy(subpool);
if (kind == svn_node_dir)
- /* Buh-bye, old and busted ... */
- SVN_ERR(relegate_dir_external(path,
- ctx->wc_ctx,
- ctx->cancel_func,
- ctx->cancel_baton,
- pool));
+ {
+ struct relegate_dir_external_with_write_lock_baton baton;
+
+ SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
+
+ baton.local_abspath = local_abspath;
+ baton.wc_ctx = ctx->wc_ctx;
+ baton.cancel_func = ctx->cancel_func;
+ baton.cancel_baton = ctx->cancel_baton;
+
+ /* Buh-bye, old and busted ... */
+ SVN_ERR(svn_wc__call_with_write_lock(relegate_dir_external, &baton,
+ ctx->wc_ctx, local_abspath,
+ pool, pool));
+ }
else
{
/* The target dir might have multiple components. Guarantee
Modified: subversion/trunk/subversion/libsvn_client/revert.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/revert.c?rev=906267&r1=906266&r2=906267&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/revert.c (original)
+++ subversion/trunk/subversion/libsvn_client/revert.c Wed Feb 3 22:16:00 2010
@@ -41,7 +41,17 @@
/*** Code. ***/
-/* Attempt to revert PATH.
+struct revert_with_write_lock_baton {
+ const char *local_abspath;
+ svn_depth_t depth;
+ svn_boolean_t use_commit_times;
+ const apr_array_header_t *changelists;
+ svn_client_ctx_t *ctx;
+};
+
+/* (Note: All arguments are in the baton above.)
+
+ Attempt to revert LOCAL_ABSPATH.
If DEPTH is svn_depth_empty, revert just the properties on the
directory; else if svn_depth_files, revert the properties and any
@@ -56,34 +66,23 @@
CHANGELISTS is empty (or altogether NULL), no changelist filtering occurs.
Consult CTX to determine whether or not to revert timestamp to the
- time of last commit ('use-commit-times = yes'). Use POOL for
- temporary allocation.
+ time of last commit ('use-commit-times = yes').
If PATH is unversioned, return SVN_ERR_UNVERSIONED_RESOURCE. */
static svn_error_t *
-revert(const char *path,
- svn_depth_t depth,
- svn_boolean_t use_commit_times,
- const apr_array_header_t *changelists,
- svn_client_ctx_t *ctx,
- apr_pool_t *pool)
+revert(void *baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool)
{
- const char *local_abspath, *anchor_abspath;
+ struct revert_with_write_lock_baton *b = baton;
svn_error_t *err;
- SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
-
- SVN_ERR(svn_wc__acquire_write_lock(&anchor_abspath, ctx->wc_ctx,
- local_abspath, pool, pool));
-
- err = svn_wc_revert4(ctx->wc_ctx,
- local_abspath,
- depth,
- use_commit_times,
- changelists,
- ctx->cancel_func, ctx->cancel_baton,
- ctx->notify_func2, ctx->notify_baton2,
- pool);
+ err = svn_wc_revert4(b->ctx->wc_ctx,
+ b->local_abspath,
+ b->depth,
+ b->use_commit_times,
+ b->changelists,
+ b->ctx->cancel_func, b->ctx->cancel_baton,
+ b->ctx->notify_func2, b->ctx->notify_baton2,
+ scratch_pool);
if (err)
{
@@ -92,19 +91,19 @@
if (err->apr_err == SVN_ERR_ENTRY_NOT_FOUND
|| err->apr_err == SVN_ERR_UNVERSIONED_RESOURCE)
{
- if (ctx->notify_func2)
- (*ctx->notify_func2)
- (ctx->notify_baton2,
- svn_wc_create_notify(path, svn_wc_notify_skip, pool),
- pool);
+ if (b->ctx->notify_func2)
+ (*b->ctx->notify_func2)
+ (b->ctx->notify_baton2,
+ svn_wc_create_notify(b->local_abspath, svn_wc_notify_skip,
+ scratch_pool),
+ scratch_pool);
svn_error_clear(err);
}
else
return svn_error_return(err);
}
- return svn_error_return(
- svn_wc__release_write_lock(ctx->wc_ctx, anchor_abspath, pool));
+ return SVN_NO_ERROR;
}
@@ -120,6 +119,7 @@
int i;
svn_config_t *cfg;
svn_boolean_t use_commit_times;
+ struct revert_with_write_lock_baton baton;
cfg = ctx->config ? apr_hash_get(ctx->config, SVN_CONFIG_CATEGORY_CONFIG,
APR_HASH_KEY_STRING) : NULL;
@@ -134,6 +134,7 @@
for (i = 0; i < paths->nelts; i++)
{
const char *path = APR_ARRAY_IDX(paths, i, const char *);
+ const char *local_abspath;
svn_pool_clear(subpool);
@@ -142,7 +143,15 @@
&& ((err = ctx->cancel_func(ctx->cancel_baton))))
goto errorful;
- err = revert(path, depth, use_commit_times, changelists, ctx, subpool);
+ SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
+
+ baton.local_abspath = local_abspath;
+ baton.depth = depth;
+ baton.use_commit_times = use_commit_times;
+ baton.changelists = changelists;
+ baton.ctx = ctx;
+ err = svn_wc__call_with_write_lock(revert, &baton, ctx->wc_ctx,
+ local_abspath, pool, pool);
if (err)
goto errorful;
}