Author: julianfoad
Date: Wed Apr 4 15:39:08 2012
New Revision: 1309463
URL: http://svn.apache.org/viewvc?rev=1309463&view=rev
Log:
Simplify more client code a little, using path-rev.
* subversion/include/private/svn_client_private.h,
subversion/libsvn_client/util.c
(svn_client__pathrev_join_relpath, svn_client__pathrev_fspath): New
functions.
(svn_client__pathrev_dup): Rename a parameter, for consistency.
* subversion/libsvn_client/checkout.c
(initialize_area, svn_client__checkout_internal): Use path-rev structs
instead of separate parameters and variables.
* subversion/libsvn_client/info.c
(build_info_from_dirent, push_dir_info, svn_client_info3): Same.
* subversion/libsvn_client/merge.c
(find_unsynced_ranges, find_unmerged_mergeinfo): Simplify a little, using
the new functions.
* subversion/libsvn_client/ra.c
(svn_client__get_youngest_common_ancestor): Simplify a little, using
svn_client__pathrev_create_with_relpath().
Modified:
subversion/trunk/subversion/include/private/svn_client_private.h
subversion/trunk/subversion/libsvn_client/checkout.c
subversion/trunk/subversion/libsvn_client/info.c
subversion/trunk/subversion/libsvn_client/merge.c
subversion/trunk/subversion/libsvn_client/ra.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=1309463&r1=1309462&r2=1309463&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_client_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_client_private.h Wed Apr 4
15:39:08 2012
@@ -76,16 +76,28 @@ svn_client__pathrev_create_with_session(
const char *url,
apr_pool_t *result_pool);
-/* Return a deep copy of the path-rev LOC, allocated in RESULT_POOL. */
+/* Return a deep copy of PATHREV, allocated in RESULT_POOL. */
svn_client__pathrev_t *
-svn_client__pathrev_dup(const svn_client__pathrev_t *loc,
+svn_client__pathrev_dup(const svn_client__pathrev_t *pathrev,
apr_pool_t *result_pool);
+/* Return a deep copy of PATHREV, with a URI-encoded representation of
+ * RELPATH joined on to the URL. Allocate the result in RESULT_POOL. */
+svn_client__pathrev_t *
+svn_client__pathrev_join_relpath(const svn_client__pathrev_t *pathrev,
+ const char *relpath,
+ apr_pool_t *result_pool);
+
/* Return the repository-relative relpath of PATHREV. */
const char *
svn_client__pathrev_relpath(const svn_client__pathrev_t *pathrev,
apr_pool_t *result_pool);
+/* Return the repository-relative fspath of PATHREV. */
+const char *
+svn_client__pathrev_fspath(const svn_client__pathrev_t *pathrev,
+ apr_pool_t *result_pool);
+
/** Return @c SVN_ERR_ILLEGAL_TARGET if TARGETS contains a mixture of
* URLs and paths; otherwise return SVN_NO_ERROR.
Modified: subversion/trunk/subversion/libsvn_client/checkout.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/checkout.c?rev=1309463&r1=1309462&r2=1309463&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/checkout.c (original)
+++ subversion/trunk/subversion/libsvn_client/checkout.c Wed Apr 4 15:39:08
2012
@@ -49,10 +49,7 @@
static svn_error_t *
initialize_area(const char *local_abspath,
- const char *session_url,
- const char *repos_root,
- const char *uuid,
- svn_revnum_t revnum,
+ const svn_client__pathrev_t *pathrev,
svn_depth_t depth,
svn_client_ctx_t *ctx,
apr_pool_t *pool)
@@ -61,8 +58,9 @@ initialize_area(const char *local_abspat
depth = svn_depth_infinity;
/* Make the unversioned directory into a versioned one. */
- SVN_ERR(svn_wc_ensure_adm4(ctx->wc_ctx, local_abspath, session_url,
- repos_root, uuid, revnum, depth, pool));
+ SVN_ERR(svn_wc_ensure_adm4(ctx->wc_ctx, local_abspath, pathrev->url,
+ pathrev->repos_root_url, pathrev->repos_uuid,
+ pathrev->rev, depth, pool));
return SVN_NO_ERROR;
}
@@ -81,16 +79,12 @@ svn_client__checkout_internal(svn_revnum
apr_pool_t *pool)
{
svn_error_t *err = NULL;
- svn_revnum_t revnum;
svn_boolean_t sleep_here = FALSE;
svn_boolean_t *use_sleep = timestamp_sleep ? timestamp_sleep : &sleep_here;
- const char *session_url;
svn_node_kind_t kind;
- const char *uuid, *repos_root;
apr_pool_t *session_pool = svn_pool_create(pool);
svn_ra_session_t *ra_session;
- svn_revnum_t tmp_revnum;
- const char *tmp_session_url;
+ svn_client__pathrev_t *pathrev;
/* Sanity check. Without these, the checkout is meaningless. */
SVN_ERR_ASSERT(local_abspath != NULL);
@@ -104,26 +98,22 @@ svn_client__checkout_internal(svn_revnum
return svn_error_create(SVN_ERR_CLIENT_BAD_REVISION, NULL, NULL);
/* Get the RA connection. */
- SVN_ERR(svn_client__ra_session_from_path(&ra_session, &tmp_revnum,
- &tmp_session_url, url, NULL,
- peg_revision, revision, ctx,
- session_pool));
-
- SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root, pool));
- SVN_ERR(svn_ra_get_uuid2(ra_session, &uuid, pool));
- session_url = apr_pstrdup(pool, tmp_session_url);
- revnum = tmp_revnum;
- SVN_ERR(svn_ra_check_path(ra_session, "", revnum, &kind, pool));
+ SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &pathrev,
+ url, NULL, peg_revision, revision,
+ ctx, session_pool));
+
+ pathrev = svn_client__pathrev_dup(pathrev, pool);
+ SVN_ERR(svn_ra_check_path(ra_session, "", pathrev->rev, &kind, pool));
svn_pool_destroy(session_pool);
if (kind == svn_node_none)
return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
- _("URL '%s' doesn't exist"), session_url);
+ _("URL '%s' doesn't exist"), pathrev->url);
else if (kind == svn_node_file)
return svn_error_createf
(SVN_ERR_UNSUPPORTED_FEATURE , NULL,
- _("URL '%s' refers to a file, not a directory"), session_url);
+ _("URL '%s' refers to a file, not a directory"), pathrev->url);
SVN_ERR(svn_io_check_path(local_abspath, &kind, pool));
@@ -133,8 +123,7 @@ svn_client__checkout_internal(svn_revnum
entries file should only have an entry for THIS_DIR with a
URL, revnum, and an 'incomplete' flag. */
SVN_ERR(svn_io_make_dir_recursively(local_abspath, pool));
- err = initialize_area(local_abspath, session_url,
- repos_root, uuid, revnum, depth, ctx, pool);
+ err = initialize_area(local_abspath, pathrev, depth, ctx, pool);
}
else if (kind == svn_node_dir)
{
@@ -144,8 +133,7 @@ svn_client__checkout_internal(svn_revnum
SVN_ERR(svn_wc_check_wc2(&wc_format, ctx->wc_ctx, local_abspath, pool));
if (! wc_format)
{
- err = initialize_area(local_abspath, session_url,
- repos_root, uuid, revnum, depth, ctx, pool);
+ err = initialize_area(local_abspath, pathrev, depth, ctx, pool);
}
else
{
@@ -156,7 +144,7 @@ svn_client__checkout_internal(svn_revnum
/* If PATH's existing URL matches the incoming one, then
just update. This allows 'svn co' to restart an
interrupted checkout. Otherwise bail out. */
- if (strcmp(entry_url, session_url) != 0)
+ if (strcmp(entry_url, pathrev->url) != 0)
return svn_error_createf(
SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL,
_("'%s' is already a working copy for a"
Modified: subversion/trunk/subversion/libsvn_client/info.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/info.c?rev=1309463&r1=1309462&r2=1309463&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/info.c (original)
+++ subversion/trunk/subversion/libsvn_client/info.c Wed Apr 4 15:39:08 2012
@@ -66,19 +66,16 @@ static svn_error_t *
build_info_from_dirent(svn_client_info2_t **info,
const svn_dirent_t *dirent,
svn_lock_t *lock,
- const char *URL,
- svn_revnum_t revision,
- const char *repos_UUID,
- const char *repos_root,
+ const svn_client__pathrev_t *pathrev,
apr_pool_t *pool)
{
svn_client_info2_t *tmpinfo = apr_pcalloc(pool, sizeof(*tmpinfo));
- tmpinfo->URL = URL;
- tmpinfo->rev = revision;
+ tmpinfo->URL = pathrev->url;
+ tmpinfo->rev = pathrev->rev;
tmpinfo->kind = dirent->kind;
- tmpinfo->repos_UUID = repos_UUID;
- tmpinfo->repos_root_URL = repos_root;
+ tmpinfo->repos_UUID = pathrev->repos_uuid;
+ tmpinfo->repos_root_URL = pathrev->repos_root_url;
tmpinfo->last_changed_rev = dirent->created_rev;
tmpinfo->last_changed_date = dirent->time;
tmpinfo->last_changed_author = dirent->last_author;
@@ -111,11 +108,8 @@ build_info_from_dirent(svn_client_info2_
*/
static svn_error_t *
push_dir_info(svn_ra_session_t *ra_session,
- const char *session_URL,
+ const svn_client__pathrev_t *pathrev,
const char *dir,
- svn_revnum_t rev,
- const char *repos_UUID,
- const char *repos_root,
svn_client_info_receiver2_t receiver,
void *receiver_baton,
svn_depth_t depth,
@@ -128,15 +122,16 @@ push_dir_info(svn_ra_session_t *ra_sessi
apr_pool_t *subpool = svn_pool_create(pool);
SVN_ERR(svn_ra_get_dir2(ra_session, &tmpdirents, NULL, NULL,
- dir, rev, DIRENT_FIELDS, pool));
+ dir, pathrev->rev, DIRENT_FIELDS, pool));
for (hi = apr_hash_first(pool, tmpdirents); hi; hi = apr_hash_next(hi))
{
- const char *path, *URL, *fs_path;
+ const char *path, *fs_path;
svn_lock_t *lock;
svn_client_info2_t *info;
const char *name = svn__apr_hash_index_key(hi);
svn_dirent_t *the_ent = svn__apr_hash_index_val(hi);
+ svn_client__pathrev_t *child_pathrev;
svn_pool_clear(subpool);
@@ -144,14 +139,13 @@ push_dir_info(svn_ra_session_t *ra_sessi
SVN_ERR(ctx->cancel_func(ctx->cancel_baton));
path = svn_relpath_join(dir, name, subpool);
- URL = svn_path_url_add_component2(session_URL, name, subpool);
- fs_path = svn_fspath__canonicalize(
- svn_uri_skip_ancestor(repos_root, URL, subpool), subpool);
+ child_pathrev = svn_client__pathrev_join_relpath(pathrev, name, subpool);
+ fs_path = svn_client__pathrev_fspath(child_pathrev, subpool);
lock = apr_hash_get(locks, fs_path, APR_HASH_KEY_STRING);
- SVN_ERR(build_info_from_dirent(&info, the_ent, lock, URL, rev,
- repos_UUID, repos_root, subpool));
+ SVN_ERR(build_info_from_dirent(&info, the_ent, lock, child_pathrev,
+ subpool));
if (depth >= svn_depth_immediates
|| (depth == svn_depth_files && the_ent->kind == svn_node_file))
@@ -161,8 +155,7 @@ push_dir_info(svn_ra_session_t *ra_sessi
if (depth == svn_depth_infinity && the_ent->kind == svn_node_dir)
{
- SVN_ERR(push_dir_info(ra_session, URL, path,
- rev, repos_UUID, repos_root,
+ SVN_ERR(push_dir_info(ra_session, child_pathrev, path,
receiver, receiver_baton,
depth, ctx, locks, subpool));
}
@@ -338,9 +331,7 @@ svn_client_info3(const char *abspath_or_
apr_pool_t *pool)
{
svn_ra_session_t *ra_session;
- svn_revnum_t rev;
- const char *url;
- const char *repos_root_URL, *repos_UUID;
+ svn_client__pathrev_t *pathrev;
svn_lock_t *lock;
svn_boolean_t related;
const char *base_name;
@@ -370,18 +361,14 @@ svn_client_info3(const char *abspath_or_
/* Trace rename history (starting at path_or_url@peg_revision) and
return RA session to the possibly-renamed URL as it exists in REVISION.
The ra_session returned will be anchored on this "final" URL. */
- SVN_ERR(svn_client__ra_session_from_path(&ra_session, &rev,
- &url, abspath_or_url, NULL,
- peg_revision,
- revision, ctx, pool));
+ SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &pathrev,
+ abspath_or_url, NULL, peg_revision,
+ revision, ctx, pool));
- SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root_URL, pool));
- SVN_ERR(svn_ra_get_uuid2(ra_session, &repos_UUID, pool));
-
- svn_uri_split(NULL, &base_name, url, pool);
+ svn_uri_split(NULL, &base_name, pathrev->url, pool);
/* Get the dirent for the URL itself. */
- err = ra_stat_compatible(ra_session, rev, &the_ent, DIRENT_FIELDS,
+ err = ra_stat_compatible(ra_session, pathrev->rev, &the_ent, DIRENT_FIELDS,
ctx, pool);
if (err && err->apr_err == SVN_ERR_RA_NOT_IMPLEMENTED)
{
@@ -407,7 +394,7 @@ svn_client_info3(const char *abspath_or_
if (! the_ent)
return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
_("URL '%s' non-existent in revision %ld"),
- url, rev);
+ pathrev->url, pathrev->rev);
/* Check if the URL exists in HEAD and refers to the same resource.
In this case, we check the repository for a lock on this URL.
@@ -417,7 +404,8 @@ svn_client_info3(const char *abspath_or_
### check in a loop which only terminates if the HEAD revision is the same
### before and after this check. That could, however, lead to a
### starvation situation instead. */
- SVN_ERR(same_resource_in_head(&related, url, rev, ra_session, ctx, pool));
+ SVN_ERR(same_resource_in_head(&related, pathrev->url, pathrev->rev,
+ ra_session, ctx, pool));
if (related)
{
err = svn_ra_get_lock(ra_session, &lock, "", pool);
@@ -437,8 +425,7 @@ svn_client_info3(const char *abspath_or_
lock = NULL;
/* Push the URL's dirent (and lock) at the callback.*/
- SVN_ERR(build_info_from_dirent(&info, the_ent, lock, url, rev,
- repos_UUID, repos_root_URL, pool));
+ SVN_ERR(build_info_from_dirent(&info, the_ent, lock, pathrev, pool));
SVN_ERR(receiver(receiver_baton, base_name, info, pool));
/* Possibly recurse, using the original RA session. */
@@ -466,8 +453,7 @@ pre_1_2_recurse:
else
locks = apr_hash_make(pool); /* use an empty hash */
- SVN_ERR(push_dir_info(ra_session, url, "", rev,
- repos_UUID, repos_root_URL,
+ SVN_ERR(push_dir_info(ra_session, pathrev, "",
receiver, receiver_baton,
depth, ctx, locks, pool));
}
Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1309463&r1=1309462&r2=1309463&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Wed Apr 4 15:39:08 2012
@@ -9843,10 +9843,6 @@ find_unsynced_ranges(const svn_client__p
are not yet merged to it. */
if (potentially_unmerged_ranges)
{
- const char *source_repos_rel_path
- = svn_client__pathrev_relpath(source_loc, scratch_pool);
- const char *target_repos_rel_path
- = svn_client__pathrev_relpath(target_loc, scratch_pool);
svn_revnum_t oldest_rev =
(APR_ARRAY_IDX(potentially_unmerged_ranges,
0,
@@ -9861,9 +9857,10 @@ find_unsynced_ranges(const svn_client__p
log_baton.merged_catalog = merged_catalog;
log_baton.unmerged_catalog = true_unmerged_catalog;
- log_baton.source_repos_rel_path = source_repos_rel_path;
- log_baton.target_fspath = apr_psprintf(scratch_pool, "/%s",
- target_repos_rel_path);
+ log_baton.source_repos_rel_path
+ = svn_client__pathrev_relpath(source_loc, scratch_pool);
+ log_baton.target_fspath
+ = svn_client__pathrev_fspath(target_loc, scratch_pool);
log_baton.result_pool = result_pool;
APR_ARRAY_PUSH(log_targets, const char *) = "";
@@ -10153,7 +10150,6 @@ find_unmerged_mergeinfo(svn_mergeinfo_ca
const char *source_url;
svn_mergeinfo_t source_mergeinfo = svn__apr_hash_index_val(hi);
svn_mergeinfo_t filtered_mergeinfo;
- const char *target_url;
svn_client__pathrev_t *target_pathrev;
svn_mergeinfo_t target_history_as_mergeinfo;
svn_error_t *err;
@@ -10162,11 +10158,8 @@ find_unmerged_mergeinfo(svn_mergeinfo_ca
source_url = svn_path_url_add_component2(source_session_url,
path_rel_to_session, iterpool);
- target_url = svn_path_url_add_component2(target->loc.url,
- path_rel_to_session, iterpool);
- target_pathrev = svn_client__pathrev_create(
- target->loc.repos_root_url, target->loc.repos_uuid,
- target->loc.rev, target_url, iterpool);
+ target_pathrev = svn_client__pathrev_join_relpath(
+ &target->loc, path_rel_to_session, iterpool);
err = svn_client__get_history_as_mergeinfo(&target_history_as_mergeinfo,
NULL /* has_rev_zero_history
*/,
target_pathrev,
Modified: subversion/trunk/subversion/libsvn_client/ra.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ra.c?rev=1309463&r1=1309462&r2=1309463&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ra.c (original)
+++ subversion/trunk/subversion/libsvn_client/ra.c Wed Apr 4 15:39:08 2012
@@ -913,12 +913,9 @@ svn_client__get_youngest_common_ancestor
if (yc_relpath)
{
- const char *yc_url = svn_path_url_add_component2(
- loc1->repos_root_url, yc_relpath, result_pool);
-
- *ancestor_p = svn_client__pathrev_create(
+ *ancestor_p = svn_client__pathrev_create_with_relpath(
loc1->repos_root_url, loc1->repos_uuid,
- yc_revision, yc_url, result_pool);
+ yc_revision, yc_relpath, result_pool);
}
else
{
Modified: subversion/trunk/subversion/libsvn_client/util.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/util.c?rev=1309463&r1=1309462&r2=1309463&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/util.c (original)
+++ subversion/trunk/subversion/libsvn_client/util.c Wed Apr 4 15:39:08 2012
@@ -96,11 +96,23 @@ svn_client__pathrev_create_with_session(
}
svn_client__pathrev_t *
-svn_client__pathrev_dup(const svn_client__pathrev_t *loc,
+svn_client__pathrev_dup(const svn_client__pathrev_t *pathrev,
apr_pool_t *result_pool)
{
- return svn_client__pathrev_create(loc->repos_root_url, loc->repos_uuid,
- loc->rev, loc->url, result_pool);
+ return svn_client__pathrev_create(
+ pathrev->repos_root_url, pathrev->repos_uuid,
+ pathrev->rev, pathrev->url, result_pool);
+}
+
+svn_client__pathrev_t *
+svn_client__pathrev_join_relpath(const svn_client__pathrev_t *pathrev,
+ const char *relpath,
+ apr_pool_t *result_pool)
+{
+ return svn_client__pathrev_create(
+ pathrev->repos_root_url, pathrev->repos_uuid, pathrev->rev,
+ svn_path_url_add_component2(pathrev->url, relpath, result_pool),
+ result_pool);
}
const char *
@@ -111,6 +123,17 @@ svn_client__pathrev_relpath(const svn_cl
result_pool);
}
+const char *
+svn_client__pathrev_fspath(const svn_client__pathrev_t *pathrev,
+ apr_pool_t *result_pool)
+{
+ return svn_fspath__canonicalize(svn_uri_skip_ancestor(
+ pathrev->repos_root_url, pathrev->url,
+ result_pool),
+ result_pool);
+}
+
+
svn_client_commit_item3_t *
svn_client_commit_item3_create(apr_pool_t *pool)
{