You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2012/05/11 23:47:21 UTC
svn commit: r1337392 -
/subversion/trunk/subversion/libsvn_client/commit_util.c
Author: rhuijben
Date: Fri May 11 21:47:21 2012
New Revision: 1337392
URL: http://svn.apache.org/viewvc?rev=1337392&view=rev
Log:
Following up on r1337281, make the commit harvester use the status walker
recursion instead of its own recursion for the svn cp WC URL case.
In other words: remove the recursion inside this function.
Move the code to handle not-present nodes as deletes to a helper function to
avoid making more functional changes than necessary in this commit.
* subversion/libsvn_client/commit_util.c
(harvest_baton): Remove got_one boolean.
(harvest_committables): Always pass depth to the status walker.
Separate the WC to url copy code specific code to...
(harvest_not_present_for_copy): ... this new function, called from
harvest_status_callback().
(harvest_status_callback): Remove recursion. Simplify the skip expression.
Handle not present children.
Modified:
subversion/trunk/subversion/libsvn_client/commit_util.c
Modified: subversion/trunk/subversion/libsvn_client/commit_util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit_util.c?rev=1337392&r1=1337391&r2=1337392&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit_util.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit_util.c Fri May 11 21:47:21 2012
@@ -377,7 +377,6 @@ struct harvest_baton
apr_pool_t *result_pool;
/* Harvester state */
- svn_boolean_t got_one;
const char *skip_below_abspath; /* If non-NULL, skip everything below */
};
@@ -432,13 +431,11 @@ harvest_committables(const char *local_a
baton.wc_ctx = wc_ctx;
baton.result_pool = result_pool;
- baton.got_one = FALSE;
baton.skip_below_abspath = NULL;
SVN_ERR(svn_wc_walk_status(wc_ctx,
local_abspath,
- (commit_relpath != NULL)
- ? svn_depth_empty : depth,
+ depth,
(commit_relpath != NULL) /* get_all */,
TRUE /* no_ignore */,
FALSE /* ignore_text_mods */,
@@ -448,24 +445,49 @@ harvest_committables(const char *local_a
cancel_func, cancel_baton,
scratch_pool));
- /* ### HACK: Make sure that not-present nodes in svn cp WC URL scenarios
- are properly handled. This should/will be moved outside this walker
- in a followup commit */
- if (commit_relpath && !baton.got_one)
- {
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+harvest_not_present_for_copy(struct harvest_baton *baton,
+ const char *local_abspath,
+ const char *repos_root_url,
+ const char *commit_relpath,
+ apr_pool_t *scratch_pool)
+{
+ svn_wc_context_t *wc_ctx = baton->wc_ctx;
+ const apr_array_header_t *children;
+ apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+ int i;
+
+ SVN_ERR(svn_wc__node_get_children_of_working_node(
+ &children, wc_ctx, local_abspath, TRUE,
+ scratch_pool, iterpool));
+
+ for (i = 0; i < children->nelts; i++)
+ {
+ const char *this_abspath = APR_ARRAY_IDX(children, i, const char *);
+ const char *name = svn_dirent_basename(this_abspath, NULL);
+ const char *this_commit_relpath;
svn_boolean_t not_present;
svn_node_kind_t kind;
- /* The status callback isn't called for not-present leaves, but we might
- have to commit them anyway */
+ svn_pool_clear(iterpool);
+
SVN_ERR(svn_wc__node_is_status_not_present(¬_present, wc_ctx,
- local_abspath, scratch_pool));
+ this_abspath, scratch_pool));
if (!not_present)
- return SVN_NO_ERROR;
+ continue;
+
+ if (commit_relpath == NULL)
+ this_commit_relpath = NULL;
+ else
+ this_commit_relpath = svn_relpath_join(commit_relpath, name,
+ iterpool);
/* We should check if we should really add a delete operation */
- if (check_url_func)
+ if (baton->check_url_func)
{
svn_revnum_t rev;
const char *repos_relpath;
@@ -473,40 +495,43 @@ harvest_committables(const char *local_a
const char *node_url;
/* Determine from what parent we would be the deleted child */
- SVN_ERR(svn_wc__node_get_origin(NULL, &rev, &repos_relpath,
- &repos_root_url, NULL, NULL,
- wc_ctx,
- svn_dirent_dirname(local_abspath,
- scratch_pool),
- FALSE, scratch_pool, scratch_pool));
+ SVN_ERR(svn_wc__node_get_origin(
+ NULL, &rev, &repos_relpath,
+ &repos_root_url, NULL, NULL,
+ wc_ctx,
+ svn_dirent_dirname(this_abspath,
+ scratch_pool),
+ FALSE, scratch_pool, scratch_pool));
node_url = svn_path_url_add_component2(
svn_path_url_add_component2(repos_root_url,
repos_relpath,
scratch_pool),
- svn_dirent_basename(local_abspath, NULL),
- scratch_pool);
+ svn_dirent_basename(this_abspath, NULL),
+ iterpool);
- SVN_ERR(check_url_func(check_url_baton, &kind, node_url, rev,
- scratch_pool));
+ SVN_ERR(baton->check_url_func(baton->check_url_baton, &kind,
+ node_url, rev,
+ iterpool));
if (kind == svn_node_none)
- return SVN_NO_ERROR; /* This node can't be deleted */
+ continue; /* This node can't be deleted */
}
else
- SVN_ERR(svn_wc_read_kind(&kind, wc_ctx, local_abspath, TRUE,
+ SVN_ERR(svn_wc_read_kind(&kind, wc_ctx, this_abspath, TRUE,
scratch_pool));
- SVN_ERR(add_committable(committables, local_abspath, kind,
+ SVN_ERR(add_committable(baton->committables, this_abspath, kind,
repos_root_url,
- commit_relpath,
+ this_commit_relpath,
SVN_INVALID_REVNUM,
NULL /* copyfrom_relpath */,
SVN_INVALID_REVNUM /* copyfrom_rev */,
SVN_CLIENT_COMMIT_ITEM_DELETE,
- result_pool, scratch_pool));
+ baton->result_pool, scratch_pool));
}
+ svn_pool_destroy(iterpool);
return SVN_NO_ERROR;
}
@@ -566,8 +591,6 @@ harvest_status_callback(void *status_bat
svn_wc_context_t *wc_ctx = baton->wc_ctx;
apr_pool_t *result_pool = baton->result_pool;
- baton->got_one = TRUE;
-
if (baton->commit_relpath)
commit_relpath = svn_relpath_join(
baton->commit_relpath,
@@ -946,66 +969,23 @@ harvest_status_callback(void *status_bat
if (db_kind != svn_node_dir || depth <= svn_depth_empty)
return SVN_NO_ERROR;
- if (!commit_relpath)
+ if ((state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE)
+ && !(state_flags & SVN_CLIENT_COMMIT_ITEM_ADD))
{
- if (! ((! (state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE))
- || (state_flags & SVN_CLIENT_COMMIT_ITEM_ADD)))
- {
- /* Skip all descendants, like what the loop below would do */
- baton->skip_below_abspath = apr_pstrdup(baton->result_pool,
- local_abspath);
- }
+ /* Skip all descendants */
+ baton->skip_below_abspath = apr_pstrdup(baton->result_pool,
+ local_abspath);
return SVN_NO_ERROR;
}
/* Recursively handle each node according to depth, except when the
- node is only being deleted. */
- if ((! (state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE))
- || (state_flags & SVN_CLIENT_COMMIT_ITEM_ADD))
- {
- const apr_array_header_t *children;
- apr_pool_t *iterpool = svn_pool_create(scratch_pool);
- int i;
- svn_depth_t depth_below_here = depth;
-
- if (depth < svn_depth_infinity)
- depth_below_here = svn_depth_empty; /* Stop recursing */
-
- SVN_ERR(svn_wc__node_get_children_of_working_node(
- &children, wc_ctx, local_abspath, copy_mode,
- scratch_pool, iterpool));
- for (i = 0; i < children->nelts; i++)
- {
- const char *this_abspath = APR_ARRAY_IDX(children, i, const char *);
- const char *name = svn_dirent_basename(this_abspath, NULL);
- const char *this_commit_relpath;
-
- svn_pool_clear(iterpool);
-
- if (commit_relpath == NULL)
- this_commit_relpath = NULL;
- else
- this_commit_relpath = svn_relpath_join(commit_relpath, name,
- iterpool);
-
- SVN_ERR(harvest_committables(this_abspath,
- committables, lock_tokens,
- repos_root_url,
- this_commit_relpath,
- FALSE, /* COPY_MODE_ROOT */
- depth_below_here,
- just_locked,
- changelists,
- (depth < svn_depth_files),
- FALSE, /* IS_EXPLICIT_TARGET */
- danglers,
- check_url_func, check_url_baton,
- cancel_func, cancel_baton,
- notify_func, notify_baton,
- wc_ctx, result_pool, iterpool));
- }
-
- svn_pool_destroy(iterpool);
+ node is only being deleted, or is in an added tree (as added trees
+ use the normal commit handling). */
+ if (copy_mode && !is_added && !is_deleted)
+ {
+ SVN_ERR(harvest_not_present_for_copy(baton, local_abspath,
+ repos_root_url, commit_relpath,
+ scratch_pool));
}
return SVN_NO_ERROR;
Re: svn commit: r1337392 - /subversion/trunk/subversion/libsvn_client/commit_util.c
Posted by Greg Stein <gs...@gmail.com>.
On Fri, May 11, 2012 at 5:47 PM, <rh...@apache.org> wrote:
>...
> +++ subversion/trunk/subversion/libsvn_client/commit_util.c Fri May 11 21:47:21 2012
>...
> +static svn_error_t *
> +harvest_not_present_for_copy(struct harvest_baton *baton,
> + const char *local_abspath,
> + const char *repos_root_url,
> + const char *commit_relpath,
> + apr_pool_t *scratch_pool)
This function doesn't need the whole BATON. There are only five values
needed (and one is RESULT_POOL which is normal dual-pool design rather
than "another argument"). Another is WC_CTX which is also kind of
invisible. So you're really just swapping out BATON for
CHECK_URL_FUNC/BATON and COMMITTABLES.
>...
Cheers,
-g