Author: julianfoad
Date: Thu Jan 12 14:27:05 2012
New Revision: 1230563
URL: http://svn.apache.org/viewvc?rev=1230563&view=rev
Log:
Change svn_client__repos_location_segments() not to take a path relative
to the RA session but instead a URL and an RA session that is parented
anywhere in the correct repository. This fits better with the general style
of libsvn_client, simplifying usage in typical cases.
(In this patch, find_unmerged_mergeinfo() temporarily becomes more complex
because additional work is needed to generate the URLs, but afterwards we
will be able to simplify it by converting it to use
svn_client__get_history_as_mergeinfo() instead.)
* subversion/libsvn_client/client.h,
subversion/libsvn_client/ra.c
(svn_client__repos_location_segments): Take a URL instead of a relative
path. Allow the RA session to be parented anywhere in the repository.
* subversion/libsvn_client/merge.c
(adjust_deleted_subtree_ranges, normalize_merge_sources_internal,
find_unmerged_mergeinfo, calculate_left_hand_side): Adjust calls to pass
a URL to svn_client__repos_location_segments().
* subversion/libsvn_client/mergeinfo.c
(svn_client__get_history_as_mergeinfo): Pass the URL instead of a relative
path to svn_client__repos_location_segments(), and don't bother
reparenting around that call.
Modified:
subversion/trunk/subversion/libsvn_client/client.h
subversion/trunk/subversion/libsvn_client/merge.c
subversion/trunk/subversion/libsvn_client/mergeinfo.c
subversion/trunk/subversion/libsvn_client/ra.c
Modified: subversion/trunk/subversion/libsvn_client/client.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/client.h?rev=1230563&r1=1230562&r2=1230563&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Thu Jan 12 14:27:05 2012
@@ -163,8 +163,8 @@ svn_client__repos_location(const char **
/* Set *SEGMENTS to an array of svn_location_segment_t * objects, each
- representing a reposition location segment for the history of PATH
- (which is relative to RA_SESSION's session URL) in PEG_REVISION
+ representing a reposition location segment for the history of URL
+ in PEG_REVISION
between END_REVISION and START_REVISION, ordered from oldest
segment to youngest. *SEGMENTS may be empty but it will never
be NULL.
@@ -173,13 +173,16 @@ svn_client__repos_location(const char **
svn_ra_get_location_segments() interface, which see for the rules
governing PEG_REVISION, START_REVISION, and END_REVISION.
+ RA_SESSION is an RA session open to the repository of URL; it may be
+ temporarily reparented within this function.
+
CTX is the client context baton.
Use POOL for all allocations. */
svn_error_t *
svn_client__repos_location_segments(apr_array_header_t **segments,
svn_ra_session_t *ra_session,
- const char *path,
+ const char *url,
svn_revnum_t peg_revision,
svn_revnum_t start_revision,
svn_revnum_t end_revision,
Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1230563&r1=1230562&r2=1230563&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Thu Jan 12 14:27:05 2012
@@ -3149,17 +3149,12 @@ adjust_deleted_subtree_ranges(svn_client
svn_revnum_t peg_rev = younger_rev;
svn_revnum_t older_rev = is_rollback ? revision2 : revision1;
apr_array_header_t *segments;
- const char *rel_source_path;
svn_error_t *err;
SVN_ERR_ASSERT(parent->remaining_ranges);
- /* We want to know about PRIMARY_URL@peg_rev, but we need PRIMARY_URL's
- path relative to RA_SESSION's URL. */
- SVN_ERR(svn_ra_get_path_relative_to_session(ra_session, &rel_source_path,
- primary_url, scratch_pool));
err = svn_client__repos_location_segments(&segments, ra_session,
- rel_source_path, peg_rev,
+ primary_url, peg_rev,
younger_rev, older_rev, ctx,
scratch_pool);
@@ -3178,10 +3173,15 @@ adjust_deleted_subtree_ranges(svn_client
/* PRIMARY_URL@peg_rev doesn't exist. Check if PRIMARY_URL@older_rev
exists, if neither exist then the editor can simply ignore this
subtree. */
+ const char *rel_source_path; /* PRIMARY_URL relative to RA_SESSION
*/
svn_node_kind_t kind;
svn_error_clear(err);
err = NULL;
+
+ SVN_ERR(svn_ra_get_path_relative_to_session(
+ ra_session, &rel_source_path, primary_url, scratch_pool));
+
SVN_ERR(svn_ra_check_path(ra_session, rel_source_path,
older_rev, &kind, scratch_pool));
if (kind == svn_node_none)
@@ -6295,7 +6295,10 @@ combine_range_with_segments(apr_array_he
/* Similar to normalize_merge_sources() but:
* no SOURCE_PATH_OR_URL argument;
* MERGE_RANGE_TS (array of svn_merge_range_t *) instead of RANGES;
- * SOURCE_PEG_REVNUM instead of SOURCE_PEG_REVISION. */
+ * SOURCE_PEG_REVNUM instead of SOURCE_PEG_REVISION.
+ * RA_SESSION is an RA session open to the repository of SOURCE_URL; it may
+ * be temporarily reparented within this function.
+ */
static svn_error_t *
normalize_merge_sources_internal(apr_array_header_t **merge_sources_p,
const char *source_url,
@@ -6342,7 +6345,7 @@ normalize_merge_sources_internal(apr_arr
/* Fetch the locations for our merge range span. */
SVN_ERR(svn_client__repos_location_segments(&segments,
- ra_session, "",
+ ra_session, source_url,
source_peg_revnum,
youngest_requested,
oldest_requested,
@@ -6464,7 +6467,8 @@ normalize_merge_sources_internal(apr_arr
RANGES_TO_MERGE (a list of svn_opt_revision_range_t's which provide
revision ranges).
- Use RA_SESSION -- whose session URL matches SOURCE_URL -- to answer
+ RA_SESSION is an RA session open to the repository of SOURCE_URL; it may
+ be temporarily reparented within this function. Use RA_SESSION to answer
historical questions.
CTX is a client context baton.
@@ -9908,6 +9912,8 @@ find_unmerged_mergeinfo(svn_mergeinfo_ca
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
+ const char *source_session_url;
+ const char *target_session_url;
apr_hash_index_t *hi;
svn_mergeinfo_catalog_t new_catalog = apr_hash_make(result_pool);
apr_pool_t *iterpool = svn_pool_create(scratch_pool);
@@ -9916,6 +9922,11 @@ find_unmerged_mergeinfo(svn_mergeinfo_ca
*never_synched = TRUE;
*youngest_merged_rev = SVN_INVALID_REVNUM;
+ SVN_ERR(svn_ra_get_session_url(target_ra_session, &target_session_url,
+ scratch_pool));
+ SVN_ERR(svn_ra_get_session_url(source_ra_session, &source_session_url,
+ scratch_pool));
+
/* Examine the natural history of each path in the reintegrate target
with explicit mergeinfo. */
for (hi = apr_hash_first(scratch_pool, target_segments_hash);
@@ -9928,12 +9939,15 @@ find_unmerged_mergeinfo(svn_mergeinfo_ca
const char *path_rel_to_session
= svn_relpath_skip_ancestor(target_repos_rel_path, target_path);
const char *source_path;
+ const char *source_url;
svn_mergeinfo_t source_mergeinfo, filtered_mergeinfo, common_mergeinfo;
svn_pool_clear(iterpool);
source_path = svn_relpath_join(source_repos_rel_path,
path_rel_to_session, iterpool);
+ source_url = svn_path_url_add_component2(source_session_url,
+ path_rel_to_session, iterpool);
/* Convert this target path's natural history into mergeinfo. */
SVN_ERR(svn_mergeinfo__mergeinfo_from_segments(
@@ -10025,7 +10039,7 @@ find_unmerged_mergeinfo(svn_mergeinfo_ca
or inherited mergeinfo. */
SVN_ERR(svn_client__repos_location_segments(&segments,
source_ra_session,
- path_rel_to_session,
+ source_url,
source_rev, source_rev,
SVN_INVALID_REVNUM,
ctx, iterpool));
@@ -10073,17 +10087,23 @@ find_unmerged_mergeinfo(svn_mergeinfo_ca
const char *source_path = svn__apr_hash_index_key(hi);
const char *path_rel_to_session =
svn_relpath_skip_ancestor(source_repos_rel_path, source_path);
+ const char *source_url;
svn_mergeinfo_t source_mergeinfo = svn__apr_hash_index_val(hi);
svn_mergeinfo_t filtered_mergeinfo, common_mergeinfo;
+ const char *target_url;
apr_array_header_t *segments;
svn_mergeinfo_t target_history_as_mergeinfo, source_history_as_mergeinfo;
svn_error_t *err;
svn_pool_clear(iterpool);
+ source_url = svn_path_url_add_component2(source_session_url,
+ path_rel_to_session, iterpool);
+ target_url = svn_path_url_add_component2(target_session_url,
+ path_rel_to_session, iterpool);
err = svn_client__repos_location_segments(&segments,
target_ra_session,
- path_rel_to_session,
+ target_url,
target_rev, target_rev,
SVN_INVALID_REVNUM,
ctx, iterpool);
@@ -10137,7 +10157,7 @@ find_unmerged_mergeinfo(svn_mergeinfo_ca
SVN_ERR(svn_client__repos_location_segments(
&segments,
source_ra_session,
- path_rel_to_session,
+ source_url,
target_rev,
target_rev,
SVN_INVALID_REVNUM,
@@ -10235,6 +10255,7 @@ calculate_left_hand_side(const char **ur
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
+ const char *target_repos_root_url = source_repos_root; /* necessarily */
apr_array_header_t *segments; /* array of (svn_location_segment_t *) */
svn_mergeinfo_catalog_t mergeinfo_catalog, unmerged_catalog;
apr_array_header_t *source_repos_rel_path_as_array
@@ -10270,7 +10291,7 @@ calculate_left_hand_side(const char **ur
hi = apr_hash_next(hi))
{
const char *absolute_path = svn__apr_hash_index_key(hi);
- const char *path_rel_to_session;
+ const char *url;
const char *path_rel_to_root;
svn_pool_clear(iterpool);
@@ -10282,11 +10303,11 @@ calculate_left_hand_side(const char **ur
NULL, FALSE,
NULL, scratch_pool,
iterpool));
- path_rel_to_session = svn_relpath_skip_ancestor(target_repos_rel_path,
- path_rel_to_root);
+ url = svn_path_url_add_component2(target_repos_root_url,
+ path_rel_to_root, iterpool);
SVN_ERR(svn_client__repos_location_segments(&segments,
target_ra_session,
- path_rel_to_session,
+ url,
target_rev, target_rev,
SVN_INVALID_REVNUM,
ctx, scratch_pool));
Modified: subversion/trunk/subversion/libsvn_client/mergeinfo.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mergeinfo.c?rev=1230563&r1=1230562&r2=1230563&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_client/mergeinfo.c Thu Jan 12 14:27:05
2012
@@ -756,7 +756,6 @@ svn_client__get_history_as_mergeinfo(svn
svn_client_ctx_t *ctx,
apr_pool_t *pool)
{
- const char *old_session_url;
apr_array_header_t *segments;
/* Fetch the location segments for our URL@PEG_REVNUM. */
@@ -765,12 +764,9 @@ svn_client__get_history_as_mergeinfo(svn
if (! SVN_IS_VALID_REVNUM(range_oldest))
range_oldest = 0;
- SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url, ra_session,
- url, pool));
- SVN_ERR(svn_client__repos_location_segments(&segments, ra_session, "",
+ SVN_ERR(svn_client__repos_location_segments(&segments, ra_session, url,
peg_revnum, range_youngest,
range_oldest, ctx, pool));
- SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
if (has_rev_zero_history)
{
Modified: subversion/trunk/subversion/libsvn_client/ra.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ra.c?rev=1230563&r1=1230562&r2=1230563&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ra.c (original)
+++ subversion/trunk/subversion/libsvn_client/ra.c Thu Jan 12 14:27:05 2012
@@ -551,7 +551,7 @@ compare_segments(const void *a, const vo
svn_error_t *
svn_client__repos_location_segments(apr_array_header_t **segments,
svn_ra_session_t *ra_session,
- const char *path,
+ const char *url,
svn_revnum_t peg_revision,
svn_revnum_t start_revision,
svn_revnum_t end_revision,
@@ -559,14 +559,19 @@ svn_client__repos_location_segments(apr_
apr_pool_t *pool)
{
struct gls_receiver_baton_t gls_receiver_baton;
+ const char *old_session_url;
+
*segments = apr_array_make(pool, 8, sizeof(svn_location_segment_t *));
gls_receiver_baton.segments = *segments;
gls_receiver_baton.ctx = ctx;
gls_receiver_baton.pool = pool;
- SVN_ERR(svn_ra_get_location_segments(ra_session, path, peg_revision,
+ SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url, ra_session,
+ url, pool));
+ SVN_ERR(svn_ra_get_location_segments(ra_session, "", peg_revision,
start_revision, end_revision,
gls_receiver, &gls_receiver_baton,
pool));
+ SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
qsort((*segments)->elts, (*segments)->nelts,
(*segments)->elt_size, compare_segments);
return SVN_NO_ERROR;