You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2012/05/14 13:22:41 UTC
svn commit: r1338158 - in /subversion/trunk/subversion:
include/private/svn_client_private.h libsvn_client/switch.c
libsvn_client/update.c libsvn_client/util.c
Author: julianfoad
Date: Mon May 14 11:22:40 2012
New Revision: 1338158
URL: http://svn.apache.org/viewvc?rev=1338158&view=rev
Log:
Simplify some code by introducing svn_client__wc_node_get_base() as a
wrapper around svn_wc__node_get_base() that yields the outputs as a single
path-rev structure, similar to svn_client__wc_node_get_origin().
* subversion/include/private/svn_client_private.h,
subversion/libsvn_client/util.c
(svn_client__wc_node_get_base): New function.
(svn_client__wc_node_get_origin): Expand the doc string to be similar to
that of svn_client__wc_node_get_base().
* subversion/libsvn_client/switch.c
(switch_internal): Simplify by using svn_client__wc_node_get_base()
instead of svn_wc__node_get_base().
* subversion/libsvn_client/update.c
(update_internal): Same.
Modified:
subversion/trunk/subversion/include/private/svn_client_private.h
subversion/trunk/subversion/libsvn_client/switch.c
subversion/trunk/subversion/libsvn_client/update.c
subversion/trunk/subversion/libsvn_client/util.c
Modified: subversion/trunk/subversion/include/private/svn_client_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_client_private.h?rev=1338158&r1=1338157&r2=1338158&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_client_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_client_private.h Mon May 14 11:22:40 2012
@@ -144,9 +144,33 @@ svn_client__youngest_common_ancestor(con
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
-/* Set *ORIGIN_P to the origin of the WC node at WC_ABSPATH. If the node
+/* Get the repository location of the base node at LOCAL_ABSPATH.
+ *
+ * A pathrev_t wrapper around svn_wc__node_get_base().
+ *
+ * Set *BASE_P to the location that this node was checked out at or last
+ * updated/switched to, regardless of any uncommitted changes (delete,
+ * replace and/or copy-here/move-here).
+ *
+ * If there is no base node at LOCAL_ABSPATH (such as when there is a
+ * locally added/copied/moved-here node that is not part of a replace),
+ * set *BASE_P to NULL.
+ */
+svn_error_t *
+svn_client__wc_node_get_base(svn_client__pathrev_t **base_p,
+ const char *wc_abspath,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
+/* Get the original location of the WC node at LOCAL_ABSPATH.
+ *
+ * A pathrev_t wrapper around svn_wc__node_get_origin().
+ *
+ * Set *ORIGIN_P to the origin of the WC node at WC_ABSPATH. If the node
* is a local copy, give the copy-from location. If the node is locally
- * added or deleted, set *ORIGIN_P to NULL. */
+ * added or deleted, set *ORIGIN_P to NULL.
+ */
svn_error_t *
svn_client__wc_node_get_origin(svn_client__pathrev_t **origin_p,
const char *wc_abspath,
Modified: subversion/trunk/subversion/libsvn_client/switch.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/switch.c?rev=1338158&r1=1338157&r2=1338158&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/switch.c (original)
+++ subversion/trunk/subversion/libsvn_client/switch.c Mon May 14 11:22:40 2012
@@ -197,33 +197,21 @@ switch_internal(svn_revnum_t *result_rev
### okay? */
if (! ignore_ancestry)
{
- const char *repos_root_url;
- const char *repos_relpath;
- svn_revnum_t target_rev;
- svn_client__pathrev_t *switch_loc, *target_loc, *yca;
+ svn_client__pathrev_t *switch_loc, *target_base_loc, *yca;
SVN_ERR(svn_client__pathrev_create_with_session(
&switch_loc, ra_session, revnum, switch_rev_url, pool));
- SVN_ERR(svn_wc__node_get_base(&target_rev, &repos_relpath,
- &repos_root_url, NULL, ctx->wc_ctx,
- local_abspath, pool, pool));
+ SVN_ERR(svn_client__wc_node_get_base(&target_base_loc, local_abspath,
+ ctx, pool, pool));
- if (!repos_relpath)
+ if (!target_base_loc)
yca = NULL; /* Not versioned */
else
{
- const char *url = svn_path_url_add_component2(repos_root_url,
- repos_relpath, pool);
-
- SVN_ERR(svn_client__pathrev_create_with_session(&target_loc,
- ra_session,
- target_rev, url,
- pool));
-
/* ### It would be nice if this function could reuse the existing
ra session instead of opening two for its own use. */
SVN_ERR(svn_client__get_youngest_common_ancestor(
- &yca, switch_loc, target_loc, ctx, pool, pool));
+ &yca, switch_loc, target_base_loc, ctx, pool, pool));
}
if (! yca)
return svn_error_createf(SVN_ERR_CLIENT_UNRELATED_RESOURCES, NULL,
Modified: subversion/trunk/subversion/libsvn_client/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/update.c?rev=1338158&r1=1338157&r2=1338158&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/update.c (original)
+++ subversion/trunk/subversion/libsvn_client/update.c Mon May 14 11:22:40 2012
@@ -191,11 +191,9 @@ update_internal(svn_revnum_t *result_rev
void *update_edit_baton;
const svn_ra_reporter3_t *reporter;
void *report_baton;
- const char *anchor_url;
const char *corrected_url;
const char *target;
- const char *repos_root_url;
- const char *repos_relpath;
+ svn_client__pathrev_t *anchor_loc;
svn_error_t *err;
svn_revnum_t revnum;
svn_boolean_t use_commit_times;
@@ -223,8 +221,8 @@ update_internal(svn_revnum_t *result_rev
target = "";
/* Check if our anchor exists in BASE. If it doesn't we can't update. */
- SVN_ERR(svn_wc__node_get_base(&revnum, &repos_relpath, &repos_root_url, NULL,
- ctx->wc_ctx, anchor_abspath, pool, pool));
+ SVN_ERR(svn_client__wc_node_get_base(&anchor_loc, anchor_abspath,
+ ctx, pool, pool));
/* It does not make sense to update conflict victims. */
err = svn_wc_conflicted_p3(&text_conflicted, &prop_conflicted,
@@ -240,7 +238,7 @@ update_internal(svn_revnum_t *result_rev
else
SVN_ERR(err);
- if (!SVN_IS_VALID_REVNUM(revnum)
+ if (! anchor_loc
|| text_conflicted || prop_conflicted || tree_conflicted)
{
if (ctx->notify_func2)
@@ -258,11 +256,6 @@ update_internal(svn_revnum_t *result_rev
}
return SVN_NO_ERROR;
}
- else
- SVN_ERR_ASSERT(repos_relpath);
-
- anchor_url = svn_path_url_add_component2(repos_root_url, repos_relpath,
- pool);
/* We may need to crop the tree if the depth is sticky */
if (depth_is_sticky && depth < svn_depth_infinity)
@@ -331,7 +324,7 @@ update_internal(svn_revnum_t *result_rev
/* Open an RA session for the URL */
SVN_ERR(svn_client__open_ra_session_internal(&ra_session, &corrected_url,
- anchor_url,
+ anchor_loc->url,
anchor_abspath, NULL, TRUE,
TRUE, ctx, pool));
@@ -346,13 +339,15 @@ update_internal(svn_revnum_t *result_rev
SVN_ERR(svn_ra_get_repos_root2(ra_session, &new_repos_root_url, pool));
/* svn_client_relocate2() will check the uuid */
- SVN_ERR(svn_client_relocate2(anchor_abspath, repos_root_url,
+ SVN_ERR(svn_client_relocate2(anchor_abspath, anchor_loc->url,
new_repos_root_url, ignore_externals,
ctx, pool));
/* Store updated repository root for externals */
- repos_root_url = new_repos_root_url;
- anchor_url = corrected_url;
+ anchor_loc->repos_root_url = new_repos_root_url;
+ /* ### We should update anchor_loc->repos_uuid too, although currently
+ * we don't use it. */
+ anchor_loc->url = corrected_url;
}
/* ### todo: shouldn't svn_client__get_revision_number be able
@@ -366,7 +361,7 @@ update_internal(svn_revnum_t *result_rev
dfb.ra_session = ra_session;
dfb.target_revision = revnum;
- dfb.anchor_url = anchor_url;
+ dfb.anchor_url = anchor_loc->url;
/* Fetch the update editor. If REVISION is invalid, that's okay;
the RA driver will call editor->set_target_revision later on. */
@@ -428,7 +423,7 @@ update_internal(svn_revnum_t *result_rev
SVN_ERR(svn_client__handle_externals(new_externals,
new_depths,
- repos_root_url, local_abspath,
+ anchor_loc->repos_root_url, local_abspath,
depth, use_sleep,
ctx, pool));
}
Modified: subversion/trunk/subversion/libsvn_client/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/util.c?rev=1338158&r1=1338157&r2=1338158&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/util.c (original)
+++ subversion/trunk/subversion/libsvn_client/util.c Mon May 14 11:22:40 2012
@@ -232,6 +232,35 @@ svn_client__path_relative_to_root(const
}
svn_error_t *
+svn_client__wc_node_get_base(svn_client__pathrev_t **base_p,
+ const char *wc_abspath,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ const char *relpath;
+
+ *base_p = apr_palloc(result_pool, sizeof(**base_p));
+
+ SVN_ERR(svn_wc__node_get_base(&(*base_p)->rev,
+ &relpath,
+ &(*base_p)->repos_root_url,
+ &(*base_p)->repos_uuid,
+ ctx->wc_ctx, wc_abspath,
+ result_pool, scratch_pool));
+ if ((*base_p)->repos_root_url && relpath)
+ {
+ (*base_p)->url = svn_path_url_add_component2(
+ (*base_p)->repos_root_url, relpath, result_pool);
+ }
+ else
+ {
+ *base_p = NULL;
+ }
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
svn_client__wc_node_get_origin(svn_client__pathrev_t **origin_p,
const char *wc_abspath,
svn_client_ctx_t *ctx,