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/03/15 19:50:02 UTC
svn commit: r1301139 - in /subversion/trunk/subversion:
include/private/svn_client_private.h libsvn_client/commit_util.c
libsvn_client/copy.c libsvn_client/merge.c libsvn_client/mergeinfo.c
libsvn_client/util.c
Author: julianfoad
Date: Thu Mar 15 18:50:01 2012
New Revision: 1301139
URL: http://svn.apache.org/viewvc?rev=1301139&view=rev
Log:
Factor out a bit of code.
* subversion/include/private/svn_client_private.h,
subversion/libsvn_client/util.c
(svn_client__wc_node_get_origin): New function.
* subversion/libsvn_client/copy.c
(calculate_target_mergeinfo): Use svn_client__wc_node_get_origin() for
simplicity.
* subversion/libsvn_client/merge.c
(get_full_mergeinfo, target_node_location): Same.
* subversion/libsvn_client/mergeinfo.c
(get_mergeinfo): Same.
* subversion/libsvn_client/commit_util.c
(harvest_committables): Same. Take a client ctx parameter instead of a
wc_ctx, to enable this.
(svn_client__harvest_committables, harvest_copy_committables): Adjust
calls to harvest_committables().
Modified:
subversion/trunk/subversion/include/private/svn_client_private.h
subversion/trunk/subversion/libsvn_client/commit_util.c
subversion/trunk/subversion/libsvn_client/copy.c
subversion/trunk/subversion/libsvn_client/merge.c
subversion/trunk/subversion/libsvn_client/mergeinfo.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=1301139&r1=1301138&r2=1301139&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_client_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_client_private.h Thu Mar 15 18:50:01 2012
@@ -82,6 +82,24 @@ svn_client__youngest_common_ancestor(con
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
+/* Set *REPOS_ROOT_URL_P, *REPOS_UUID_P, *REV and *URL 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 *REV and *URL
+ * to SVN_INVALID_REVNUM and NULL respectively, but still give the correct
+ * repository root URL and UUID.
+ *
+ * Any outputs may be NULL if not wanted.
+ */
+svn_error_t *
+svn_client__wc_node_get_origin(const char **repos_root_url_p,
+ const char **repos_uuid_p,
+ svn_revnum_t *rev_p,
+ const char **url_p,
+ const char *wc_abspath,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
Modified: subversion/trunk/subversion/libsvn_client/commit_util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit_util.c?rev=1301139&r1=1301138&r2=1301139&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit_util.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit_util.c Thu Mar 15 18:50:01 2012
@@ -44,6 +44,7 @@
#include "svn_private_config.h"
#include "private/svn_wc_private.h"
+#include "private/svn_client_private.h"
/*** Uncomment this to turn on commit driver debugging. ***/
/*
@@ -426,8 +427,7 @@ bail_on_tree_conflicted_ancestor(svn_wc_
Any items added to COMMITTABLES are allocated from the COMITTABLES
hash pool, not POOL. SCRATCH_POOL is used for temporary allocations. */
static svn_error_t *
-harvest_committables(svn_wc_context_t *wc_ctx,
- const char *local_abspath,
+harvest_committables(const char *local_abspath,
svn_client__committables_t *committables,
apr_hash_t *lock_tokens,
const char *repos_root_url,
@@ -446,9 +446,11 @@ harvest_committables(svn_wc_context_t *w
void *cancel_baton,
svn_wc_notify_func2_t notify_func,
void *notify_baton,
+ svn_client_ctx_t *ctx,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
+ svn_wc_context_t *wc_ctx = ctx->wc_ctx;
svn_boolean_t text_mod = FALSE;
svn_boolean_t prop_mod = FALSE;
apr_byte_t state_flags = 0;
@@ -627,26 +629,21 @@ harvest_committables(svn_wc_context_t *w
if (check_url_func)
{
svn_revnum_t revision;
- const char *repos_relpath;
+ const char *repos_url;
svn_node_kind_t kind;
/* Determine from what parent we would be the deleted child */
- SVN_ERR(svn_wc__node_get_origin(NULL, &revision, &repos_relpath,
- NULL, NULL, NULL, wc_ctx,
- svn_dirent_dirname(local_abspath,
- scratch_pool),
- FALSE, scratch_pool, scratch_pool));
+ SVN_ERR(svn_client__wc_node_get_origin(
+ NULL, NULL, &revision, &repos_url,
+ svn_dirent_dirname(local_abspath, scratch_pool),
+ ctx, scratch_pool, scratch_pool));
+
+ repos_url = svn_path_url_add_component2(
+ repos_url, svn_dirent_basename(local_abspath, NULL),
+ scratch_pool);
- repos_relpath = svn_relpath_join(repos_relpath,
- svn_dirent_basename(local_abspath,
- NULL),
- scratch_pool);
-
- SVN_ERR(check_url_func(check_url_baton, &kind,
- svn_path_url_add_component2(repos_root_url,
- repos_relpath,
- scratch_pool),
- revision, scratch_pool));
+ SVN_ERR(check_url_func(check_url_baton, &kind, repos_url, revision,
+ scratch_pool));
if (kind == svn_node_none)
return SVN_NO_ERROR; /* This node can't be deleted */
@@ -896,7 +893,7 @@ harvest_committables(svn_wc_context_t *w
this_commit_relpath = svn_relpath_join(commit_relpath, name,
iterpool);
- SVN_ERR(harvest_committables(wc_ctx, this_abspath,
+ SVN_ERR(harvest_committables(this_abspath,
committables, lock_tokens,
repos_root_url,
this_commit_relpath,
@@ -911,8 +908,7 @@ harvest_committables(svn_wc_context_t *w
check_url_func, check_url_baton,
cancel_func, cancel_baton,
notify_func, notify_baton,
- result_pool,
- iterpool));
+ ctx, result_pool, iterpool));
}
svn_pool_destroy(iterpool);
@@ -1154,7 +1150,7 @@ svn_client__harvest_committables(svn_cli
ctx->notify_baton2,
iterpool));
- SVN_ERR(harvest_committables(ctx->wc_ctx, target_abspath,
+ SVN_ERR(harvest_committables(target_abspath,
*committables, *lock_tokens,
repos_root_url,
NULL /* COMMIT_RELPATH */,
@@ -1166,7 +1162,7 @@ svn_client__harvest_committables(svn_cli
check_url_func, check_url_baton,
ctx->cancel_func, ctx->cancel_baton,
ctx->notify_func2, ctx->notify_baton2,
- result_pool, iterpool));
+ ctx, result_pool, iterpool));
}
hdb.wc_ctx = ctx->wc_ctx;
@@ -1246,8 +1242,7 @@ harvest_copy_committables(void *baton, v
pair->dst_abspath_or_url, pool);
/* Handle this SRC. */
- SVN_ERR(harvest_committables(btn->ctx->wc_ctx,
- pair->src_abspath_or_url,
+ SVN_ERR(harvest_committables(pair->src_abspath_or_url,
btn->committables, NULL,
repos_root_url,
commit_relpath,
@@ -1264,7 +1259,7 @@ harvest_copy_committables(void *baton, v
btn->ctx->cancel_baton,
btn->ctx->notify_func2,
btn->ctx->notify_baton2,
- btn->result_pool, pool));
+ btn->ctx, btn->result_pool, pool));
hdb.wc_ctx = btn->ctx->wc_ctx;
hdb.cancel_func = btn->ctx->cancel_func;
Modified: subversion/trunk/subversion/libsvn_client/copy.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy.c?rev=1301139&r1=1301138&r2=1301139&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Thu Mar 15 18:50:01 2012
@@ -46,6 +46,7 @@
#include "private/svn_wc_private.h"
#include "private/svn_ra_private.h"
#include "private/svn_mergeinfo_private.h"
+#include "private/svn_client_private.h"
/*
@@ -92,23 +93,14 @@ calculate_target_mergeinfo(svn_ra_sessio
bother checking. */
if (local_abspath)
{
- const char *repos_root_url;
- const char *repos_relpath;
-
SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath));
- SVN_ERR(svn_wc__node_get_origin(NULL, &src_revnum,
- &repos_relpath, &repos_root_url,
- NULL, NULL,
- ctx->wc_ctx, local_abspath, FALSE,
- pool, pool));
+ SVN_ERR(svn_client__wc_node_get_origin(NULL, NULL,
+ &src_revnum, &src_url,
+ local_abspath, ctx,
+ pool, pool));
- if (repos_relpath)
- {
- src_url = svn_path_url_add_component2(repos_root_url, repos_relpath,
- pool);
- }
- else
+ if (! src_url)
locally_added = TRUE;
}
Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1301139&r1=1301138&r2=1301139&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Thu Mar 15 18:50:01 2012
@@ -58,6 +58,7 @@
#include "private/svn_mergeinfo_private.h"
#include "private/svn_fspath.h"
#include "private/svn_ra_private.h"
+#include "private/svn_client_private.h"
#include "svn_private_config.h"
@@ -3508,9 +3509,8 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
if (implicit_mergeinfo)
{
- const char *repos_root;
- const char *repos_relpath;
svn_revnum_t target_rev;
+ const char *target_url;
/* Assert that we have sane input. */
SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(start) && SVN_IS_VALID_REVNUM(end)
@@ -3518,18 +3518,15 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
/* Retrieve the origin (original_*) of the node, or just the
url if the node was not copied. */
- SVN_ERR(svn_wc__node_get_origin(NULL, &target_rev, &repos_relpath,
- &repos_root, NULL, NULL,
- ctx->wc_ctx, target_abspath, FALSE,
- scratch_pool, scratch_pool));
-
- if (! repos_relpath)
- {
- /* We've been asked to operate on a target which has no location
- * in the repository. Either it's unversioned (but attempts to
- * merge into unversioned targets should not get as far as here),
- * or it is locally added, in which case the target's implicit
- * mergeinfo is empty. */
+ SVN_ERR(svn_client__wc_node_get_origin(NULL, NULL,
+ &target_rev, &target_url,
+ target_abspath, ctx,
+ scratch_pool, scratch_pool));
+
+ if (! target_url)
+ {
+ /* We've been asked to operate on a locally added target, so its
+ * implicit mergeinfo is empty. */
*implicit_mergeinfo = apr_hash_make(result_pool);
}
else if (target_rev <= end)
@@ -3540,11 +3537,6 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
}
else
{
- const char *url;
-
- url = svn_path_url_add_component2(repos_root, repos_relpath,
- scratch_pool);
-
/* Fetch so-called "implicit mergeinfo" (that is, natural
history). */
@@ -3558,7 +3550,7 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
/* Fetch the implicit mergeinfo. */
SVN_ERR(svn_client__get_history_as_mergeinfo(implicit_mergeinfo,
NULL,
- url, target_rev,
+ target_url, target_rev,
start, end,
ra_session, ctx,
result_pool));
@@ -9265,36 +9257,16 @@ target_node_location(merge_target_t **ta
apr_pool_t *scratch_pool)
{
merge_target_t *target = apr_palloc(result_pool, sizeof(*target));
- const char *relpath;
target->abspath = apr_pstrdup(result_pool, wc_abspath);
SVN_ERR(svn_wc_read_kind(&target->kind, ctx->wc_ctx, wc_abspath, FALSE,
scratch_pool));
- SVN_ERR(svn_wc__node_get_origin(NULL /* is_copy */,
- &target->rev, &relpath,
- &target->repos_root.url,
- &target->repos_root.uuid,
- NULL, ctx->wc_ctx, wc_abspath,
- FALSE /* scan_deleted */,
- result_pool, scratch_pool));
- if (target->repos_root.url && relpath)
- {
- target->url = svn_path_url_add_component2(target->repos_root.url,
- relpath, result_pool);
- }
- else
- {
- /* It's probably a locally added node. Find the repository root URL
- * and UUID anyway, and leave the node URL and revision as NULL/INVALID.
- * Some kinds of merge can use such a target; others can't. */
- target->url = NULL;
- SVN_ERR(svn_client_get_repos_root(&target->repos_root.url,
- &target->repos_root.uuid,
- wc_abspath,
- ctx, result_pool, scratch_pool));
- }
+ SVN_ERR(svn_client__wc_node_get_origin(&target->repos_root.url,
+ &target->repos_root.uuid,
+ &target->rev, &target->url,
+ wc_abspath, ctx,
+ result_pool, scratch_pool));
- SVN_ERR_ASSERT(target->repos_root.url && target->repos_root.uuid);
*target_p = target;
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/libsvn_client/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mergeinfo.c?rev=1301139&r1=1301138&r2=1301139&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_client/mergeinfo.c Thu Mar 15 18:50:01 2012
@@ -43,6 +43,7 @@
#include "private/svn_wc_private.h"
#include "private/svn_ra_private.h"
#include "private/svn_fspath.h"
+#include "private/svn_client_private.h"
#include "client.h"
#include "mergeinfo.h"
#include "svn_private_config.h"
@@ -1063,20 +1064,13 @@ get_mergeinfo(svn_mergeinfo_catalog_t *m
contact the repository for the requested PEG_REVISION. */
if (!use_url)
{
- const char *repos_root_url;
- const char *repos_relpath;
const char *origin_url = NULL;
SVN_ERR(svn_dirent_get_absolute(&local_abspath, path_or_url,
scratch_pool));
- SVN_ERR(svn_wc__node_get_origin(NULL, &rev, &repos_relpath,
- &repos_root_url, NULL, NULL,
- ctx->wc_ctx, local_abspath, FALSE,
- scratch_pool, scratch_pool));
-
- if(repos_relpath)
- origin_url = svn_path_url_add_component2(repos_root_url, repos_relpath,
- scratch_pool);
+ SVN_ERR(svn_client__wc_node_get_origin(NULL, NULL, &rev, &origin_url,
+ local_abspath, ctx,
+ scratch_pool, scratch_pool));
if (!origin_url
|| strcmp(origin_url, url) != 0
Modified: subversion/trunk/subversion/libsvn_client/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/util.c?rev=1301139&r1=1301138&r2=1301139&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/util.c (original)
+++ subversion/trunk/subversion/libsvn_client/util.c Thu Mar 15 18:50:01 2012
@@ -142,6 +142,50 @@ svn_client__path_relative_to_root(const
}
svn_error_t *
+svn_client__wc_node_get_origin(const char **repos_root_url_p,
+ const char **repos_uuid_p,
+ svn_revnum_t *rev_p,
+ const char **url_p,
+ const char *wc_abspath,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ const char *repos_root_url, *relpath;
+
+ SVN_ERR(svn_wc__node_get_origin(NULL /* is_copy */, rev_p, &relpath,
+ &repos_root_url, repos_uuid_p,
+ NULL, ctx->wc_ctx, wc_abspath,
+ FALSE /* scan_deleted */,
+ result_pool, scratch_pool));
+ if (repos_root_url && relpath)
+ {
+ *url_p = svn_path_url_add_component2(repos_root_url, relpath,
+ result_pool);
+ }
+ else
+ {
+ /* The node has no location in the repository. It's unversioned or
+ * locally added or locally deleted.
+ *
+ * If it's locally added or deleted, find the repository root
+ * URL and UUID anyway, and leave the node URL and revision as NULL
+ * and INVALID. If it's unversioned, this will throw an error. */
+ *url_p = NULL;
+ SVN_ERR(svn_client_get_repos_root(&repos_root_url, repos_uuid_p,
+ wc_abspath,
+ ctx, result_pool, scratch_pool));
+ }
+
+ if (repos_root_url_p)
+ *repos_root_url_p = repos_root_url;
+
+ SVN_ERR_ASSERT(!repos_root_url_p || *repos_root_url_p);
+ SVN_ERR_ASSERT(!repos_uuid_p || *repos_uuid_p);
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
svn_client_get_repos_root(const char **repos_root,
const char **repos_uuid,
const char *abspath_or_url,