You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2012/04/23 14:33:03 UTC
svn commit: r1329209 [9/38] - in /subversion/branches/javahl-ra: ./ build/
build/ac-macros/ build/generator/ build/generator/templates/ build/win32/
contrib/client-side/emacs/ contrib/client-side/vim/
contrib/server-side/mod_dontdothat/ notes/ notes/ap...
Modified: subversion/branches/javahl-ra/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/libsvn_client/merge.c?rev=1329209&r1=1329208&r2=1329209&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/libsvn_client/merge.c (original)
+++ subversion/branches/javahl-ra/subversion/libsvn_client/merge.c Mon Apr 23 12:32:48 2012
@@ -48,14 +48,17 @@
#include "svn_props.h"
#include "svn_time.h"
#include "svn_sorts.h"
+#include "svn_subst.h"
#include "svn_ra.h"
#include "client.h"
#include "mergeinfo.h"
+#include "private/svn_opt_private.h"
#include "private/svn_wc_private.h"
#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"
@@ -144,7 +147,7 @@
* During mergeinfo aware merges CHILDREN_WITH_MERGEINFO is created
* by get_mergeinfo_paths() and outside of that function and its helpers
* should always meet the criteria dictated in get_mergeinfo_paths()'s doc
- * string. The elements of CHILDREN_WITH_MERGINFO should never be NULL.
+ * string. The elements of CHILDREN_WITH_MERGEINFO should never be NULL.
*
* For clarification on mergeinfo aware vs. mergeinfo unaware merges, see
* the doc string for HONOR_MERGEINFO().
@@ -155,18 +158,33 @@
/*** Repos-Diff Editor Callbacks ***/
+/* */
typedef struct merge_source_t
{
/* "left" side URL and revision (inclusive iff youngest) */
- const char *url1;
- svn_revnum_t rev1;
+ const svn_client__pathrev_t *loc1;
/* "right" side URL and revision (inclusive iff youngest) */
- const char *url2;
- svn_revnum_t rev2;
+ const svn_client__pathrev_t *loc2;
} merge_source_t;
+/* Description of the merge target root node (a WC working node) */
+typedef struct merge_target_t
+{
+ /* Absolute path to the WC node */
+ const char *abspath;
+
+ /* Node kind of the WC node (at the start of the merge) */
+ svn_node_kind_t kind;
+
+ /* The repository location of the base node of the target WC. If the node
+ * is locally added, then URL & REV are NULL & SVN_INVALID_REVNUM.
+ * REPOS_ROOT_URL and REPOS_UUID are always valid. */
+ svn_client__pathrev_t loc;
+
+} merge_target_t;
+
typedef struct merge_cmd_baton_t {
svn_boolean_t force;
svn_boolean_t dry_run;
@@ -192,10 +210,7 @@ typedef struct merge_cmd_baton_t {
const char *added_path; /* Set to the dir path whenever the
dir is added as a child of a
versioned dir (dry-run only) */
- const char *target_abspath; /* Absolute working copy target of
- the merge. */
- const char *repos_root_url; /* The repository root of the repository
- containing TARGET_ABSPATH */
+ const merge_target_t *target; /* Description of merge target node */
/* The left and right URLs and revs. The value of this field changes to
reflect the merge_source_t *currently* being merged by do_merge(). */
@@ -273,18 +288,21 @@ typedef struct merge_cmd_baton_t {
} merge_cmd_baton_t;
-/* If the merge source server is is capable of merge tracking, the left-side
+/* Return TRUE iff we should be taking account of mergeinfo in deciding what
+ changes to merge, for the merge described by MERGE_B. Specifically, that
+ is if the merge source server is capable of merge tracking, the left-side
merge source is an ancestor of the right-side (or vice-versa), the merge
- source repository is the same repository as the MERGE_B->TARGET_ABSPATH, and
- ancestry is being considered then return TRUE. */
+ source is in the same repository as the merge target, and ancestry is
+ being considered. */
#define HONOR_MERGEINFO(merge_b) ((merge_b)->mergeinfo_capable \
&& (merge_b)->sources_ancestral \
&& (merge_b)->same_repos \
&& (! (merge_b)->ignore_ancestry))
-/* If HONOR_MERGEINFO is TRUE and the merge is not a dry run
- then return TRUE. */
+/* Return TRUE iff we should be recording mergeinfo for the merge described
+ by MERGE_B. Specifically, that is if we are honoring mergeinfo and the
+ merge is not a dry run. */
#define RECORD_MERGEINFO(merge_b) (HONOR_MERGEINFO(merge_b) \
&& !(merge_b)->dry_run)
@@ -293,12 +311,32 @@ typedef struct merge_cmd_baton_t {
/*** Utilities ***/
-/* Repository root and UUID for a repository. */
-typedef struct url_uuid_t
-{
- const char *url;
- const char *uuid;
-} url_uuid_t;
+/* Return a new merge_source_t structure, allocated in RESULT_POOL,
+ * initialized with deep copies of LOC1 and LOC2. */
+static merge_source_t *
+merge_source_create(const svn_client__pathrev_t *loc1,
+ const svn_client__pathrev_t *loc2,
+ apr_pool_t *result_pool)
+{
+ merge_source_t *s
+ = apr_palloc(result_pool, sizeof(*s));
+
+ s->loc1 = svn_client__pathrev_dup(loc1, result_pool);
+ s->loc2 = svn_client__pathrev_dup(loc2, result_pool);
+ return s;
+}
+
+/* Return a deep copy of SOURCE, allocated in RESULT_POOL. */
+static merge_source_t *
+merge_source_dup(const merge_source_t *source,
+ apr_pool_t *result_pool)
+{
+ merge_source_t *s = apr_palloc(result_pool, sizeof(*s));
+
+ s->loc1 = svn_client__pathrev_dup(source->loc1, result_pool);
+ s->loc2 = svn_client__pathrev_dup(source->loc2, result_pool);
+ return s;
+}
/* Return SVN_ERR_UNSUPPORTED_FEATURE if URL is not inside the repository
of LOCAL_ABSPATH. Use SCRATCH_POOL for temporary allocations. */
@@ -308,45 +346,45 @@ check_repos_match(merge_cmd_baton_t *mer
const char *url,
apr_pool_t *scratch_pool)
{
- if (!svn_uri__is_ancestor(merge_b->repos_root_url, url))
+ if (!svn_uri__is_ancestor(merge_b->target->loc.repos_root_url, url))
return svn_error_createf(
SVN_ERR_UNSUPPORTED_FEATURE, NULL,
_("Url '%s' of '%s' is not in repository '%s'"),
url, svn_dirent_local_style(local_abspath, scratch_pool),
- merge_b->repos_root_url);
+ merge_b->target->loc.repos_root_url);
return SVN_NO_ERROR;
}
-/* Return TRUE iff the repository identified by REPOS_ROOT1 is the same as
- * that identified by REPOS_ROOT2. If STRICT_URLS is true, the URLs must
+/* Return TRUE iff the repository of LOCATION1 is the same as
+ * that of LOCATION2. If STRICT_URLS is true, the URLs must
* match (and the UUIDs, just to be sure), otherwise just the UUIDs must
* match and the URLs can differ (a common case is http versus https). */
static svn_boolean_t
-is_same_repos(const url_uuid_t *repos_root1,
- const url_uuid_t *repos_root2,
+is_same_repos(const svn_client__pathrev_t *location1,
+ const svn_client__pathrev_t *location2,
svn_boolean_t strict_urls)
{
if (strict_urls)
- return (strcmp(repos_root1->url, repos_root2->url) == 0
- && strcmp(repos_root1->uuid, repos_root2->uuid) == 0);
+ return (strcmp(location1->repos_root_url, location2->repos_root_url) == 0
+ && strcmp(location1->repos_uuid, location2->repos_uuid) == 0);
else
- return (strcmp(repos_root1->uuid, repos_root2->uuid) == 0);
+ return (strcmp(location1->repos_uuid, location2->repos_uuid) == 0);
}
-/* If the repository identified by REPOS_ROOT1 is not the same as that
- * identified by REPOS_ROOT2, throw a SVN_ERR_CLIENT_UNRELATED_RESOURCES
+/* If the repository identified of LOCATION1 is not the same as that
+ * of LOCATION2, throw a SVN_ERR_CLIENT_UNRELATED_RESOURCES
* error mentioning PATH1 and PATH2. For STRICT_URLS, see is_same_repos().
*/
static svn_error_t *
-check_same_repos(const url_uuid_t *repos_root1,
+check_same_repos(const svn_client__pathrev_t *location1,
const char *path1,
- const url_uuid_t *repos_root2,
+ const svn_client__pathrev_t *location2,
const char *path2,
svn_boolean_t strict_urls,
apr_pool_t *scratch_pool)
{
- if (! is_same_repos(repos_root1, repos_root2, strict_urls))
+ if (! is_same_repos(location1, location2, strict_urls))
return svn_error_createf(SVN_ERR_CLIENT_UNRELATED_RESOURCES, NULL,
_("'%s' must be from the same repository as "
"'%s'"), path1, path2);
@@ -461,7 +499,7 @@ perform_obstruction_check(svn_wc_notify_
if (kind == NULL)
kind = &wc_kind;
- check_root = ! strcmp(local_abspath, merge_b->target_abspath);
+ check_root = ! strcmp(local_abspath, merge_b->target->abspath);
SVN_ERR(svn_wc__check_for_obstructions(obstruction_state,
kind,
@@ -492,33 +530,25 @@ make_conflict_versions(const svn_wc_conf
svn_node_kind_t node_kind,
merge_cmd_baton_t *merge_b)
{
- const char *src_repos_url; /* root URL of source repository */
- const char *left_url;
- const char *right_url;
+ const char *child = svn_dirent_skip_ancestor(merge_b->target->abspath,
+ victim_abspath);
+ const char *left_relpath, *right_relpath;
- SVN_ERR(svn_ra_get_repos_root2(merge_b->ra_session1, &src_repos_url,
- merge_b->pool));
-
- /* Construct the source URLs of the victim. */
- {
- const char *child = svn_dirent_skip_ancestor(merge_b->target_abspath,
- victim_abspath);
- SVN_ERR_ASSERT(child != NULL);
- left_url = svn_path_url_add_component2(merge_b->merge_source.url1,
- child, merge_b->pool);
- right_url = svn_path_url_add_component2(merge_b->merge_source.url2,
- child, merge_b->pool);
- }
+ SVN_ERR_ASSERT(child != NULL);
+ left_relpath = svn_client__pathrev_relpath(merge_b->merge_source.loc1,
+ merge_b->pool);
+ right_relpath = svn_client__pathrev_relpath(merge_b->merge_source.loc2,
+ merge_b->pool);
*left = svn_wc_conflict_version_create(
- src_repos_url,
- svn_uri_skip_ancestor(src_repos_url, left_url, merge_b->pool),
- merge_b->merge_source.rev1, node_kind, merge_b->pool);
+ merge_b->merge_source.loc1->repos_root_url,
+ svn_relpath_join(left_relpath, child, merge_b->pool),
+ merge_b->merge_source.loc1->rev, node_kind, merge_b->pool);
*right = svn_wc_conflict_version_create(
- src_repos_url,
- svn_uri_skip_ancestor(src_repos_url, right_url, merge_b->pool),
- merge_b->merge_source.rev2, node_kind, merge_b->pool);
+ merge_b->merge_source.loc2->repos_root_url,
+ svn_relpath_join(right_relpath, child, merge_b->pool),
+ merge_b->merge_source.loc2->rev, node_kind, merge_b->pool);
return SVN_NO_ERROR;
}
@@ -591,6 +621,7 @@ tree_conflict(merge_cmd_baton_t *merge_b
if (merge_b->conflicted_paths == NULL)
merge_b->conflicted_paths = apr_hash_make(merge_b->pool);
+ victim_abspath = apr_pstrdup(merge_b->pool, victim_abspath);
apr_hash_set(merge_b->conflicted_paths, victim_abspath,
APR_HASH_KEY_STRING, victim_abspath);
@@ -632,6 +663,7 @@ tree_conflict_on_add(merge_cmd_baton_t *
if (merge_b->conflicted_paths == NULL)
merge_b->conflicted_paths = apr_hash_make(merge_b->pool);
+ victim_abspath = apr_pstrdup(merge_b->pool, victim_abspath);
apr_hash_set(merge_b->conflicted_paths, victim_abspath,
APR_HASH_KEY_STRING, victim_abspath);
@@ -662,6 +694,7 @@ tree_conflict_on_add(merge_cmd_baton_t *
if (merge_b->conflicted_paths == NULL)
merge_b->conflicted_paths = apr_hash_make(merge_b->pool);
+ victim_abspath = apr_pstrdup(merge_b->pool, victim_abspath);
apr_hash_set(merge_b->conflicted_paths, victim_abspath,
APR_HASH_KEY_STRING, victim_abspath);
@@ -790,7 +823,7 @@ omit_mergeinfo_changes(apr_array_header_
/* Helper for merge_props_changed().
*PROPS is an array of svn_prop_t structures representing regular properties
- to be added to the working copy LOCAL_ABSPATH.
+ to be added to the working copy TARGET_ABSPATH.
HONOR_MERGEINFO determines whether mergeinfo will be honored by this
function (when applicable).
@@ -799,25 +832,28 @@ omit_mergeinfo_changes(apr_array_header_
REINTEGRATE_MERGE is FALSE do nothing. Otherwise, if
SAME_REPOS is false, then filter out all mergeinfo
property additions (Issue #3383) from *PROPS. If SAME_REPOS is
- true then filter out mergeinfo property additions to LOCAL_ABSPATH when
- those additions refer to the same line of history as LOCAL_ABSPATH as
+ true then filter out mergeinfo property additions to TARGET_ABSPATH when
+ those additions refer to the same line of history as TARGET_ABSPATH as
described below.
If mergeinfo is being honored and SAME_REPOS is true
then examine the added mergeinfo, looking at each range (or single rev)
of each source path. If a source_path/range refers to the same line of
- history as LOCAL_ABSPATH (pegged at its base revision), then filter out
+ history as TARGET_ABSPATH (pegged at its base revision), then filter out
that range. If the entire rangelist for a given path is filtered then
filter out the path as well.
- Use RA_SESSION for any communication to the repository, and CTX for any
- further client operations.
+ If SAME_REPOS is true, RA_SESSION is an open RA session to the repository
+ in which both the source and target live, else RA_SESSION is not used. It
+ may be temporarily reparented as needed by this function.
+
+ Use CTX for any further client operations.
If any filtering occurs, set outgoing *PROPS to a shallow copy (allocated
in POOL) of incoming *PROPS minus the filtered mergeinfo. */
-static svn_error_t*
+static svn_error_t *
filter_self_referential_mergeinfo(apr_array_header_t **props,
- const char *local_abspath,
+ const char *target_abspath,
svn_boolean_t honor_mergeinfo,
svn_boolean_t same_repos,
svn_boolean_t reintegrate_merge,
@@ -829,7 +865,7 @@ filter_self_referential_mergeinfo(apr_ar
int i;
apr_pool_t *iterpool;
svn_boolean_t is_added;
- svn_revnum_t base_revision;
+ svn_client__pathrev_t target_base;
/* Issue #3383: We don't want mergeinfo from a foreign repos.
@@ -853,12 +889,17 @@ filter_self_referential_mergeinfo(apr_ar
/* If this is a merge from the same repository and PATH itself has been
added there is no need to filter. */
- SVN_ERR(svn_wc__node_is_added(&is_added, ctx->wc_ctx, local_abspath, pool));
+ SVN_ERR(svn_wc__node_is_added(&is_added, ctx->wc_ctx, target_abspath, pool));
if (is_added)
return SVN_NO_ERROR;
- SVN_ERR(svn_wc__node_get_base_rev(&base_revision, ctx->wc_ctx,
- local_abspath, pool));
+ SVN_ERR(svn_wc__node_get_url(&target_base.url, ctx->wc_ctx, target_abspath,
+ pool, pool));
+ SVN_ERR(svn_wc__node_get_base_rev(&target_base.rev, ctx->wc_ctx,
+ target_abspath, pool));
+ SVN_ERR(svn_wc__node_get_repos_info(&target_base.repos_root_url,
+ &target_base.repos_uuid,
+ ctx->wc_ctx, target_abspath, pool, pool));
adjusted_props = apr_array_make(pool, (*props)->nelts, sizeof(svn_prop_t));
iterpool = svn_pool_create(pool);
@@ -869,8 +910,6 @@ filter_self_referential_mergeinfo(apr_ar
svn_mergeinfo_t mergeinfo, younger_mergeinfo;
svn_mergeinfo_t filtered_mergeinfo = NULL;
svn_mergeinfo_t filtered_younger_mergeinfo = NULL;
- const char *target_url;
- const char *old_url = NULL;
svn_error_t *err;
if ((strcmp(prop->name, SVN_PROP_MERGEINFO) != 0)
@@ -884,13 +923,6 @@ filter_self_referential_mergeinfo(apr_ar
svn_pool_clear(iterpool);
/* Non-empty mergeinfo; filter self-referential mergeinfo out. */
- /* Temporarily reparent our RA session to the merge
- target's URL. */
- SVN_ERR(svn_client_url_from_path2(&target_url, local_abspath,
- ctx, iterpool, iterpool));
- SVN_ERR(svn_client__ensure_ra_session_url(&old_url,
- ra_session,
- target_url, iterpool));
/* Parse the incoming mergeinfo to allow easier manipulation. */
err = svn_mergeinfo_parse(&mergeinfo, prop->value->data, iterpool);
@@ -903,12 +935,6 @@ filter_self_referential_mergeinfo(apr_ar
{
svn_error_clear(err);
APR_ARRAY_PUSH(adjusted_props, svn_prop_t) = *prop;
-
- /* If we reparented RA_SESSION above, put it back
- to the original URL. */
- if (old_url)
- SVN_ERR(svn_ra_reparent(ra_session, old_url, iterpool));
-
continue;
}
else
@@ -943,7 +969,7 @@ filter_self_referential_mergeinfo(apr_ar
the cost of a roundtrip communication with the repository. */
SVN_ERR(split_mergeinfo_on_revision(&younger_mergeinfo,
&mergeinfo,
- base_revision,
+ target_base.rev,
iterpool));
/* Filter self-referential mergeinfo from younger_mergeinfo. */
@@ -972,35 +998,22 @@ filter_self_referential_mergeinfo(apr_ar
for (j = 0; j < rangelist->nelts; j++)
{
svn_error_t *err2;
- const char *start_url;
- svn_opt_revision_t peg_rev, rev1_opt;
+ svn_client__pathrev_t *start_loc;
svn_merge_range_t *range =
APR_ARRAY_IDX(rangelist, j, svn_merge_range_t *);
- peg_rev.kind = svn_opt_revision_number;
- peg_rev.value.number = base_revision;
- rev1_opt.kind = svn_opt_revision_number;
- /* SVN_PROP_MERGEINFO only stores forward merges, so
- the start range of svn_merge_range_t RANGE is not
- inclusive. */
- rev1_opt.value.number = range->start + 1;
-
/* Because the merge source normalization code
ensures mergeinfo refers to real locations on
the same line of history, there's no need to
look at the whole range, just the start. */
/* Check if PATH@BASE_REVISION exists at
- RANGE->START on the same line of history. */
- err2 = svn_client__repos_locations(&start_url, NULL,
- NULL, NULL,
- ra_session,
- target_url,
- &peg_rev,
- &rev1_opt,
- NULL,
- ctx,
- iterpool);
+ RANGE->START on the same line of history.
+ (start+1 because RANGE->start is not inclusive.) */
+ err2 = svn_client__repos_location(&start_loc, ra_session,
+ &target_base,
+ range->start + 1,
+ ctx, iterpool, iterpool);
if (err2)
{
if (err2->apr_err == SVN_ERR_CLIENT_UNRELATED_RESOURCES
@@ -1045,7 +1058,7 @@ filter_self_referential_mergeinfo(apr_ar
PATH@RANGE->END actually belong to some other
line of history and we want to record this
mergeinfo, not filter it. */
- if (strcmp(start_url, merge_source_url) != 0)
+ if (strcmp(start_loc->url, merge_source_url) != 0)
{
APR_ARRAY_PUSH(adjusted_rangelist,
svn_merge_range_t *) = range;
@@ -1075,10 +1088,8 @@ filter_self_referential_mergeinfo(apr_ar
SVN_ERR(svn_client__get_history_as_mergeinfo(
&implicit_mergeinfo, NULL,
- base_revision, base_revision, SVN_INVALID_REVNUM,
- ra_session,
- ctx,
- iterpool));
+ &target_base, target_base.rev, SVN_INVALID_REVNUM,
+ ra_session, ctx, iterpool));
/* Remove PATH's implicit mergeinfo from the incoming mergeinfo. */
SVN_ERR(svn_mergeinfo_remove2(&filtered_mergeinfo,
@@ -1086,11 +1097,6 @@ filter_self_referential_mergeinfo(apr_ar
mergeinfo, TRUE, iterpool, iterpool));
}
- /* If we reparented RA_SESSION above, put it back
- to the original URL. */
- if (old_url)
- SVN_ERR(svn_ra_reparent(ra_session, old_url, iterpool));
-
/* Combine whatever older and younger filtered mergeinfo exists
into filtered_mergeinfo. */
if (filtered_mergeinfo && filtered_younger_mergeinfo)
@@ -1174,7 +1180,7 @@ merge_props_changed(svn_wc_notify_state_
http://svn.haxx.se/dev/archive-2008-09/0006.shtml. If the
merge sources are not ancestral then there is no concept of a
'forward' or 'reverse' merge and we filter unconditionally. */
- if (merge_b->merge_source.rev1 < merge_b->merge_source.rev2
+ if (merge_b->merge_source.loc1->rev < merge_b->merge_source.loc2->rev
|| !merge_b->sources_ancestral)
SVN_ERR(filter_self_referential_mergeinfo(&props,
local_abspath,
@@ -1214,8 +1220,9 @@ merge_props_changed(svn_wc_notify_state_
scratch_pool,
scratch_pool));
- if (apr_hash_get(pristine_props, SVN_PROP_MERGEINFO,
- APR_HASH_KEY_STRING))
+ if (pristine_props
+ && apr_hash_get(pristine_props, SVN_PROP_MERGEINFO,
+ APR_HASH_KEY_STRING))
has_pristine_mergeinfo = TRUE;
if (!has_pristine_mergeinfo && prop->value)
@@ -1262,6 +1269,8 @@ merge_props_changed(svn_wc_notify_state_
else if (err)
return svn_error_trace(err);
}
+ else if (state)
+ *state = svn_wc_notify_state_unchanged;
return SVN_NO_ERROR;
}
@@ -1278,7 +1287,7 @@ merge_dir_props_changed(svn_wc_notify_st
apr_pool_t *scratch_pool)
{
merge_cmd_baton_t *merge_b = diff_baton;
- const char *local_abspath = svn_dirent_join(merge_b->target_abspath,
+ const char *local_abspath = svn_dirent_join(merge_b->target->abspath,
local_relpath, scratch_pool);
svn_wc_notify_state_t obstr_state;
@@ -1321,8 +1330,8 @@ typedef struct conflict_resolver_baton_t
resolution attempt was made. */
apr_hash_t **conflicted_paths;
- /* Pool used in notification_receiver() to avoid the iteration
- sub-pool which is passed in, then subsequently destroyed. */
+ /* Pool with a sufficient lifetime to be used for output members such as
+ * *CONFLICTED_PATHS. */
apr_pool_t *pool;
} conflict_resolver_baton_t;
@@ -1394,7 +1403,7 @@ check_moved_away(svn_boolean_t *moved_aw
{
const char *moved_to_abspath;
svn_error_t *err;
-
+
*moved_away = FALSE;
err = svn_wc__node_was_moved_away(&moved_to_abspath, NULL,
@@ -1424,7 +1433,7 @@ check_moved_here(svn_boolean_t *moved_he
{
const char *moved_from_abspath;
svn_error_t *err;
-
+
*moved_here = FALSE;
err = svn_wc__node_was_moved_here(&moved_from_abspath, NULL,
@@ -1461,7 +1470,7 @@ merge_file_changed(svn_wc_notify_state_t
apr_pool_t *scratch_pool)
{
merge_cmd_baton_t *merge_b = baton;
- const char *mine_abspath = svn_dirent_join(merge_b->target_abspath,
+ const char *mine_abspath = svn_dirent_join(merge_b->target->abspath,
mine_relpath, scratch_pool);
svn_node_kind_t wc_kind;
svn_boolean_t is_deleted;
@@ -1470,6 +1479,9 @@ merge_file_changed(svn_wc_notify_state_t
SVN_ERR_ASSERT(!older_abspath || svn_dirent_is_absolute(older_abspath));
SVN_ERR_ASSERT(!yours_abspath || svn_dirent_is_absolute(yours_abspath));
+ if (tree_conflicted)
+ *tree_conflicted = FALSE;
+
/* Check for an obstructed or missing node on disk. */
{
svn_wc_notify_state_t obstr_state;
@@ -1692,7 +1704,7 @@ merge_file_added(svn_wc_notify_state_t *
apr_pool_t *scratch_pool)
{
merge_cmd_baton_t *merge_b = baton;
- const char *mine_abspath = svn_dirent_join(merge_b->target_abspath,
+ const char *mine_abspath = svn_dirent_join(merge_b->target->abspath,
mine_relpath, scratch_pool);
svn_node_kind_t kind;
int i;
@@ -1700,6 +1712,9 @@ merge_file_added(svn_wc_notify_state_t *
SVN_ERR_ASSERT(svn_dirent_is_absolute(mine_abspath));
+ if (tree_conflicted)
+ *tree_conflicted = FALSE;
+
/* Easy out: We are only applying mergeinfo differences. */
if (merge_b->record_only)
{
@@ -1727,13 +1742,13 @@ merge_file_added(svn_wc_notify_state_t *
merge-from-foreign-repository scenario) or wrong place in the
right repository (in the same-repos scenario). So we'll
strip them. (Is this a layering violation?) */
- if (svn_property_kind(NULL, prop->name) == svn_prop_wc_kind)
+ if (svn_property_kind2(prop->name) == svn_prop_wc_kind)
continue;
/* And in the foreign repository merge case, we only want
regular properties. */
if ((! merge_b->same_repos)
- && (svn_property_kind(NULL, prop->name) != svn_prop_regular_kind))
+ && (svn_property_kind2(prop->name) != svn_prop_regular_kind))
continue;
/* Issue #3383: We don't want mergeinfo from a foreign repository. */
@@ -1789,11 +1804,11 @@ merge_file_added(svn_wc_notify_state_t *
if (merge_b->same_repos)
{
const char *child =
- svn_dirent_skip_ancestor(merge_b->target_abspath,
+ svn_dirent_skip_ancestor(merge_b->target->abspath,
mine_abspath);
SVN_ERR_ASSERT(child != NULL);
copyfrom_url = svn_path_url_add_component2(
- merge_b->merge_source.url2,
+ merge_b->merge_source.loc2->url,
child, scratch_pool);
copyfrom_rev = rev2;
SVN_ERR(check_repos_match(merge_b, mine_abspath, copyfrom_url,
@@ -1987,15 +2002,17 @@ files_same_p(svn_boolean_t *same,
{
svn_stream_t *mine_stream;
svn_stream_t *older_stream;
- svn_opt_revision_t working_rev;
-
- working_rev.kind = svn_opt_revision_working;
+ svn_opt_revision_t working_rev = { svn_opt_revision_working, { 0 } };
/* Compare the file content, translating 'mine' to 'normal' form. */
- SVN_ERR(svn_client__get_normalized_stream(&mine_stream, wc_ctx,
- mine_abspath, &working_rev,
- FALSE, TRUE, NULL, NULL,
- scratch_pool, scratch_pool));
+ if (svn_prop_get_value(working_props, SVN_PROP_SPECIAL) != NULL)
+ SVN_ERR(svn_subst_read_specialfile(&mine_stream, mine_abspath,
+ scratch_pool, scratch_pool));
+ else
+ SVN_ERR(svn_client__get_normalized_stream(&mine_stream, wc_ctx,
+ mine_abspath, &working_rev,
+ FALSE, TRUE, NULL, NULL,
+ scratch_pool, scratch_pool));
SVN_ERR(svn_stream_open_readonly(&older_stream, older_abspath,
scratch_pool, scratch_pool));
@@ -2022,10 +2039,13 @@ merge_file_deleted(svn_wc_notify_state_t
apr_pool_t *scratch_pool)
{
merge_cmd_baton_t *merge_b = baton;
- const char *mine_abspath = svn_dirent_join(merge_b->target_abspath,
+ const char *mine_abspath = svn_dirent_join(merge_b->target->abspath,
mine_relpath, scratch_pool);
svn_node_kind_t kind;
+ if (tree_conflicted)
+ *tree_conflicted = FALSE;
+
if (merge_b->dry_run)
{
const char *wcpath = apr_pstrdup(merge_b->pool, mine_abspath);
@@ -2156,7 +2176,7 @@ merge_dir_added(svn_wc_notify_state_t *s
apr_pool_t *scratch_pool)
{
merge_cmd_baton_t *merge_b = baton;
- const char *local_abspath = svn_dirent_join(merge_b->target_abspath,
+ const char *local_abspath = svn_dirent_join(merge_b->target->abspath,
local_relpath, scratch_pool);
svn_node_kind_t kind;
const char *copyfrom_url = NULL, *child;
@@ -2175,7 +2195,7 @@ merge_dir_added(svn_wc_notify_state_t *s
parent_abspath = svn_dirent_dirname(local_abspath, scratch_pool);
- child = svn_dirent_is_child(merge_b->target_abspath, local_abspath, NULL);
+ child = svn_dirent_is_child(merge_b->target->abspath, local_abspath, NULL);
SVN_ERR_ASSERT(child != NULL);
/* If this is a merge from the same repository as our working copy,
@@ -2183,7 +2203,7 @@ merge_dir_added(svn_wc_notify_state_t *s
add. */
if (merge_b->same_repos)
{
- copyfrom_url = svn_path_url_add_component2(merge_b->merge_source.url2,
+ copyfrom_url = svn_path_url_add_component2(merge_b->merge_source.loc2->url,
child, scratch_pool);
copyfrom_rev = rev;
@@ -2357,7 +2377,7 @@ merge_dir_deleted(svn_wc_notify_state_t
apr_pool_t *scratch_pool)
{
merge_cmd_baton_t *merge_b = baton;
- const char *local_abspath = svn_dirent_join(merge_b->target_abspath,
+ const char *local_abspath = svn_dirent_join(merge_b->target->abspath,
local_relpath, scratch_pool);
svn_node_kind_t kind;
svn_boolean_t is_versioned;
@@ -2506,7 +2526,7 @@ merge_dir_opened(svn_boolean_t *tree_con
apr_pool_t *scratch_pool)
{
merge_cmd_baton_t *merge_b = baton;
- const char *local_abspath = svn_dirent_join(merge_b->target_abspath,
+ const char *local_abspath = svn_dirent_join(merge_b->target->abspath,
local_relpath, scratch_pool);
svn_node_kind_t wc_kind;
svn_wc_notify_state_t obstr_state;
@@ -2641,9 +2661,6 @@ typedef struct notification_receiver_bat
svn_wc_notify_func2_t wrapped_func;
void *wrapped_baton;
- /* The number of notifications received. */
- apr_uint32_t nbr_notifications;
-
/* The number of operative notifications received. */
apr_uint32_t nbr_operative_notifications;
@@ -2672,20 +2689,22 @@ typedef struct notification_receiver_bat
svn_boolean_t is_single_file_merge;
/* Depth first ordered list of paths that needs special care while merging.
+ ### And ...? This is not just a list of paths. See the global comment
+ 'THE CHILDREN_WITH_MERGEINFO ARRAY'.
This defaults to NULL. For 'same_url' merge alone we set it to
proper array. This is used by notification_receiver to put a
merge notification begin lines. */
apr_array_header_t *children_with_mergeinfo;
- /* The index in CHILDREN_WITH_MERGEINFO where we found the nearest ancestor
- for merged path. Default value is '-1'.*/
- int cur_ancestor_index;
+ /* The path in CHILDREN_WITH_MERGEINFO where we found the nearest ancestor
+ for merged path. Default value is null. */
+ const char *cur_ancestor_abspath;
/* We use this to make a decision on merge begin line notifications. */
merge_cmd_baton_t *merge_b;
- /* Pool used in notification_receiver() to avoid the iteration
- sub-pool which is passed in, then subsequently destroyed. */
+ /* Pool with a sufficient lifetime to be used for output members such as
+ * MERGED_ABSPATHS. */
apr_pool_t *pool;
} notification_receiver_baton_t;
@@ -2697,22 +2716,17 @@ typedef struct notification_receiver_bat
then child->abspath must be a proper ancestor of PATH.
CHILDREN_WITH_MERGEINFO is expected to be sorted in Depth first
- order of path. Nearest ancestor's index from
- CHILDREN_WITH_MERGEINFO is returned. */
-static int
+ order of path. */
+static svn_client__merge_path_t *
find_nearest_ancestor(const apr_array_header_t *children_with_mergeinfo,
svn_boolean_t path_is_own_ancestor,
const char *path)
{
int i;
- int ancestor_index = 0;
+ svn_client__merge_path_t *ancestor = NULL;
+
+ SVN_ERR_ASSERT_NO_RETURN(children_with_mergeinfo != NULL);
- /* This if condition is not needed as this function should be used
- from the context of same_url merge where CHILDREN_WITH_MERGEINFO
- will not be NULL and of size atleast 1. We have this if condition
- just to protect the wrong caller. */
- if (!children_with_mergeinfo)
- return 0;
for (i = 0; i < children_with_mergeinfo->nelts; i++)
{
svn_client__merge_path_t *child =
@@ -2720,12 +2734,86 @@ find_nearest_ancestor(const apr_array_he
if (svn_dirent_is_ancestor(child->abspath, path)
&& (path_is_own_ancestor
|| svn_path_compare_paths(child->abspath, path) != 0))
- ancestor_index = i;
+ ancestor = child;
+ }
+ return ancestor;
+}
+
+
+/* Notify that we're starting to record the merge of the
+ * revision range RANGE into TARGET_ABSPATH. RANGE should be null if the
+ * merge sources are not from the same URL.
+ *
+ * This calls the client's notification receiver (as found in the client
+ * context), with a WC abspath.
+ */
+static void
+notify_merge_begin(const char *target_abspath,
+ const svn_merge_range_t *range,
+ merge_cmd_baton_t *merge_b,
+ apr_pool_t *pool)
+{
+ if (merge_b->ctx->notify_func2)
+ {
+ svn_wc_notify_t *n
+ = svn_wc_create_notify(target_abspath,
+ merge_b->same_repos
+ ? svn_wc_notify_merge_begin
+ : svn_wc_notify_foreign_merge_begin,
+ pool);
+
+ n->merge_range = range ? svn_merge_range_dup(range, pool) : NULL;
+ merge_b->ctx->notify_func2(merge_b->ctx->notify_baton2, n, pool);
+ }
+}
+
+/* Notify that we're starting to record mergeinfo for the merge of the
+ * revision range RANGE into TARGET_ABSPATH. RANGE should be null if the
+ * merge sources are not from the same URL.
+ *
+ * This calls the client's notification receiver (as found in the client
+ * context), with a WC abspath.
+ */
+static void
+notify_mergeinfo_recording(const char *target_abspath,
+ const svn_merge_range_t *range,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *pool)
+{
+ if (ctx->notify_func2)
+ {
+ svn_wc_notify_t *n = svn_wc_create_notify(
+ target_abspath, svn_wc_notify_merge_record_info_begin, pool);
+
+ n->merge_range = range ? svn_merge_range_dup(range, pool) : NULL;
+ ctx->notify_func2(ctx->notify_baton2, n, pool);
}
- return ancestor_index;
}
+/* Notify that we're completing the merge into TARGET_ABSPATH.
+ *
+ * This calls the client's notification receiver (as found in the client
+ * context), with a WC abspath.
+ */
+static void
+notify_merge_completed(const char *target_abspath,
+ svn_client_ctx_t *ctx,
+ apr_pool_t *pool)
+{
+ if (ctx->notify_func2)
+ {
+ svn_wc_notify_t *n
+ = svn_wc_create_notify(target_abspath, svn_wc_notify_merge_completed,
+ pool);
+ n->kind = svn_node_none;
+ n->content_state = n->prop_state = svn_wc_notify_state_inapplicable;
+ n->lock_state = svn_wc_notify_lock_state_inapplicable;
+ n->revision = SVN_INVALID_REVNUM;
+ ctx->notify_func2(ctx->notify_baton2, n, pool);
+ }
+}
+/* Is the notification the result of a real operative merge? */
#define IS_OPERATIVE_NOTIFICATION(notify) \
(notify->content_state == svn_wc_notify_state_conflicted \
|| notify->content_state == svn_wc_notify_state_merged \
@@ -2736,13 +2824,26 @@ find_nearest_ancestor(const apr_array_he
|| notify->action == svn_wc_notify_update_add \
|| notify->action == svn_wc_notify_tree_conflict)
-/* Our svn_wc_notify_func2_t wrapper.*/
+/* Handle a diff notification by calling the client's notification callback
+ * and also by recording which paths changed (in BATON->*_abspaths).
+ *
+ * In some cases, notify that a merge is beginning, if we haven't already
+ * done so. (### TODO: Harmonize this so it handles all cases.)
+ *
+ * The paths in NOTIFY are relpaths, relative to the root of the diff (the
+ * merge source). We convert these to abspaths in the merge target WC before
+ * passing the notification structure on to the client.
+ *
+ * This function is not used for 'starting a merge', 'starting to record
+ * mergeinfo' and 'completing a merge' notifications.
+ *
+ * Implements svn_wc_notify_func2_t.*/
static void
notification_receiver(void *baton, const svn_wc_notify_t *notify,
apr_pool_t *pool)
{
notification_receiver_baton_t *notify_b = baton;
- svn_boolean_t is_operative_notification = FALSE;
+ svn_boolean_t is_operative_notification = IS_OPERATIVE_NOTIFICATION(notify);
const char *notify_abspath;
/* Skip notifications if this is a --record-only merge that is adding
@@ -2750,15 +2851,12 @@ notification_receiver(void *baton, const
We will already have skipped the actual addition or deletion, but will
still get a notification callback for it. */
if (notify_b->merge_b->record_only
- && (notify->action != svn_wc_notify_update_update
- && notify->action != svn_wc_notify_merge_record_info_begin))
+ && notify->action != svn_wc_notify_update_update)
return;
- /* Is the notification the result of a real operative merge? */
- if (IS_OPERATIVE_NOTIFICATION(notify))
+ if (is_operative_notification)
{
notify_b->nbr_operative_notifications++;
- is_operative_notification = TRUE;
}
/* If the node was moved-away, use its new path in the notification. */
@@ -2766,7 +2864,7 @@ notification_receiver(void *baton, const
* not yet implemented.
* ### We should stash the info about which moves have been followed and
* retrieve that info here, instead of querying the WC again here. */
- notify_abspath = svn_dirent_join(notify_b->merge_b->target_abspath,
+ notify_abspath = svn_dirent_join(notify_b->merge_b->target->abspath,
notify->path, pool);
if (notify->action == svn_wc_notify_update_update
&& notify->kind == svn_node_file)
@@ -2795,6 +2893,7 @@ notification_receiver(void *baton, const
notify_abspath = moved_to_abspath;
}
+ /* Update the lists of merged, skipped, tree-conflicted and added paths. */
if (notify_b->merge_b->sources_ancestral
|| notify_b->merge_b->reintegrate_merge)
{
@@ -2856,6 +2955,9 @@ notification_receiver(void *baton, const
else
{
added_path_parent = svn_dirent_dirname(added_path, pool);
+ /* ### Bug. Testing whether its immediate parent is in the
+ * hash isn't enough: this is letting every other level of
+ * the added subtree hierarchy into the hash. */
if (!apr_hash_get(notify_b->added_abspaths, added_path_parent,
APR_HASH_KEY_STRING))
is_root_of_added_subtree = TRUE;
@@ -2866,11 +2968,11 @@ notification_receiver(void *baton, const
}
}
+ /* Notify that a merge is beginning, if we haven't already done so.
+ * (A single-file merge is notified separately: see single_file_merge_notify().) */
/* If our merge sources are ancestors of one another... */
if (notify_b->merge_b->sources_ancestral)
{
- notify_b->nbr_notifications++;
-
/* See if this is an operative directory merge. */
if (!(notify_b->is_single_file_merge) && is_operative_notification)
{
@@ -2889,36 +2991,22 @@ notification_receiver(void *baton, const
--- Merging rX into 'PARENT'
D PARENT/CHILD
*/
- int new_nearest_ancestor_index =
- find_nearest_ancestor(
- notify_b->children_with_mergeinfo,
- notify->action != svn_wc_notify_update_delete,
- notify_abspath);
-
- if (new_nearest_ancestor_index != notify_b->cur_ancestor_index)
- {
- svn_client__merge_path_t *child =
- APR_ARRAY_IDX(notify_b->children_with_mergeinfo,
- new_nearest_ancestor_index,
- svn_client__merge_path_t *);
- notify_b->cur_ancestor_index = new_nearest_ancestor_index;
- if (!child->absent && child->remaining_ranges->nelts > 0
- && !(new_nearest_ancestor_index == 0
- && child->remaining_ranges == 0))
+ const svn_client__merge_path_t *child
+ = find_nearest_ancestor(
+ notify_b->children_with_mergeinfo,
+ notify->action != svn_wc_notify_update_delete,
+ notify_abspath);
+
+ if (notify_b->cur_ancestor_abspath == NULL
+ || strcmp(child->abspath, notify_b->cur_ancestor_abspath) != 0)
+ {
+ notify_b->cur_ancestor_abspath = child->abspath;
+ if (!child->absent && child->remaining_ranges->nelts > 0)
{
- svn_wc_notify_t *notify_merge_begin;
- notify_merge_begin =
- svn_wc_create_notify(child->abspath,
- notify_b->merge_b->same_repos
- ? svn_wc_notify_merge_begin
- : svn_wc_notify_foreign_merge_begin,
- pool);
- notify_merge_begin->merge_range =
- APR_ARRAY_IDX(child->remaining_ranges, 0,
- svn_merge_range_t *);
- if (notify_b->wrapped_func)
- (*notify_b->wrapped_func)(notify_b->wrapped_baton,
- notify_merge_begin, pool);
+ notify_merge_begin(child->abspath,
+ APR_ARRAY_IDX(child->remaining_ranges, 0,
+ svn_merge_range_t *),
+ notify_b->merge_b, pool);
}
}
}
@@ -2928,16 +3016,8 @@ notification_receiver(void *baton, const
&& notify_b->nbr_operative_notifications == 1
&& is_operative_notification)
{
- svn_wc_notify_t *notify_merge_begin;
- notify_merge_begin =
- svn_wc_create_notify(notify_b->merge_b->target_abspath,
- notify_b->merge_b->same_repos
- ? svn_wc_notify_merge_begin
- : svn_wc_notify_foreign_merge_begin,
- pool);
- if (notify_b->wrapped_func)
- (*notify_b->wrapped_func)(notify_b->wrapped_baton, notify_merge_begin,
- pool);
+ notify_merge_begin(notify_b->merge_b->target->abspath, NULL,
+ notify_b->merge_b, pool);
}
if (notify_b->wrapped_func)
@@ -2999,8 +3079,7 @@ rangelist_intersect_range(apr_array_head
rangelist but cannot be NULL.
PRIMARY_URL is the merge source url of CHILD at the younger of REVISION1
- and REVISION2. MERGEINFO_PATH is the absolute repository path of
- PRIMARY_URL (i.e. the path value of mergeinfo from PRIMARY_URL).
+ and REVISION2.
Since this function is only invoked for subtrees of the merge target, the
guarantees afforded by normalize_merge_sources() don't apply - see the
@@ -3031,7 +3110,7 @@ rangelist_intersect_range(apr_array_head
drive_merge_report_editor() won't attempt to describe these non-existent
subtree path/ranges to the reporter (which would break the merge).
- If the preceeding paragraph wasn't terribly clear then what follows spells
+ If the preceding paragraph wasn't terribly clear then what follows spells
out this function's behavior a bit more explicitly:
For forward merges (REVISION1 < REVISION2)
@@ -3071,7 +3150,6 @@ rangelist_intersect_range(apr_array_head
static svn_error_t *
adjust_deleted_subtree_ranges(svn_client__merge_path_t *child,
svn_client__merge_path_t *parent,
- const char *mergeinfo_path,
svn_revnum_t revision1,
svn_revnum_t revision2,
const char *primary_url,
@@ -3085,17 +3163,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);
@@ -3114,10 +3187,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)
@@ -3168,7 +3246,7 @@ adjust_deleted_subtree_ranges(svn_client
FALSE,
scratch_pool, scratch_pool));
- /* Merge into CHILD->REMANING_RANGES the intersection of
+ /* Merge into CHILD->REMAINING_RANGES the intersection of
PARENT->REMAINING_RANGES with the range beginning when
PRIMARY_URL@older_rev was deleted until younger_rev. */
SVN_ERR(rangelist_intersect_range(&deleted_rangelist,
@@ -3235,7 +3313,7 @@ adjust_deleted_subtree_ranges(svn_client
segment->range_start, peg_rev,
FALSE, scratch_pool, scratch_pool));
- /* Merge into CHILD->REMANING_RANGES the intersection of
+ /* Merge into CHILD->REMAINING_RANGES the intersection of
PARENT->REMAINING_RANGES with the range before PRIMARY_URL@peg_rev
came into existence. */
SVN_ERR(rangelist_intersect_range(&non_existent_rangelist,
@@ -3265,44 +3343,38 @@ adjust_deleted_subtree_ranges(svn_client
/* Helper for do_directory_merge().
- URL1, REVISION1, URL2, REVISION2, NOTIFY_B, and MERGE_B are
- cascaded from the arguments of the same name in do_directory_merge().
- RA_SESSION is the session for the younger of URL1@REVISION1 and
- URL2@REVISION2.
+ SOURCE and MERGE_B are cascaded from the arguments of the same name in
+ do_directory_merge(). RA_SESSION is the session for the younger of
+ SOURCE->url1@rev1 and SOURCE->url2@rev2.
- Adjust the subtrees in NOTIFY_B->CHILDREN_WITH_MERGEINFO so that we don't
+ Adjust the subtrees in CHILDREN_WITH_MERGEINFO so that we don't
later try to describe invalid paths in drive_merge_report_editor().
This function is just a thin wrapper around
adjust_deleted_subtree_ranges(), which see for further details.
SCRATCH_POOL is used for all temporary allocations. Changes to
- NOTIFY_B->CHILDREN_WITH_MERGEINFO are allocated in RESULT_POOL.
+ CHILDREN_WITH_MERGEINFO are allocated in RESULT_POOL.
*/
static svn_error_t *
-fix_deleted_subtree_ranges(const char *url1,
- svn_revnum_t revision1,
- const char *url2,
- svn_revnum_t revision2,
+fix_deleted_subtree_ranges(const merge_source_t *source,
svn_ra_session_t *ra_session,
- notification_receiver_baton_t *notify_b,
+ apr_array_header_t *children_with_mergeinfo,
merge_cmd_baton_t *merge_b,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
int i;
apr_pool_t *iterpool = svn_pool_create(scratch_pool);
- svn_boolean_t is_rollback = revision2 < revision1;
+ svn_boolean_t is_rollback = source->loc2->rev < source->loc1->rev;
- /* NOTIFY_B->CHILDREN_WITH_MERGEINFO is sorted in depth-first order, so
+ /* CHILDREN_WITH_MERGEINFO is sorted in depth-first order, so
start at index 1 to examine only subtrees. */
- for (i = 1; i < notify_b->children_with_mergeinfo->nelts; i++)
+ for (i = 1; i < children_with_mergeinfo->nelts; i++)
{
svn_client__merge_path_t *child =
- APR_ARRAY_IDX(notify_b->children_with_mergeinfo, i,
- svn_client__merge_path_t *);
+ APR_ARRAY_IDX(children_with_mergeinfo, i, svn_client__merge_path_t *);
svn_client__merge_path_t *parent;
apr_array_header_t *deleted_rangelist, *added_rangelist;
- int parent_index;
SVN_ERR_ASSERT(child);
if (child->absent)
@@ -3311,10 +3383,8 @@ fix_deleted_subtree_ranges(const char *u
svn_pool_clear(iterpool);
/* Find CHILD's parent. */
- parent_index = find_nearest_ancestor(notify_b->children_with_mergeinfo,
- FALSE, child->abspath);
- parent = APR_ARRAY_IDX(notify_b->children_with_mergeinfo, parent_index,
- svn_client__merge_path_t *);
+ parent = find_nearest_ancestor(children_with_mergeinfo,
+ FALSE, child->abspath);
/* Since CHILD is a subtree then its parent must be in
CHILDREN_WITH_MERGEINFO, see the global comment
@@ -3340,16 +3410,15 @@ fix_deleted_subtree_ranges(const char *u
SVN_ERR(svn_rangelist_reverse(parent->remaining_ranges, iterpool));
}
- /* If CHILD is the merge target we then know that URL1, URL2,
- REVISION1, and REVISION2 are provided by normalize_merge_sources()
- -- see 'MERGEINFO MERGE SOURCE NORMALIZATION'. Due to this
- normalization we know that URL1@REVISION1 and URL2@REVISION2
- describe an unbroken line of history such that the entire range
- described by REVISION1:REVISION2 can potentially be merged to CHILD.
+ /* If CHILD is the merge target we then know that SOURCE is provided
+ by normalize_merge_sources() -- see 'MERGEINFO MERGE SOURCE
+ NORMALIZATION'. Due to this normalization we know that SOURCE
+ describes an unbroken line of history such that the entire range
+ described by SOURCE can potentially be merged to CHILD.
But if CHILD is a subtree we don't have the same guarantees about
- URL1, URL2, REVISION1, and REVISION2 as we do for the merge target.
- URL1@REVSION1 and/or URL2@REVSION2 might not exist.
+ SOURCE as we do for the merge target. SOURCE->url1@rev1 and/or
+ SOURCE->url2@rev2 might not exist.
If one or both doesn't exist, then adjust CHILD->REMAINING_RANGES
such that we don't later try to describe invalid subtrees in
@@ -3360,10 +3429,9 @@ fix_deleted_subtree_ranges(const char *u
case, see the 'Note' in drive_merge_report_editor's docstring. */
if (deleted_rangelist->nelts || added_rangelist->nelts)
{
- const char *child_mergeinfo_path;
const char *child_primary_source_url;
const char *child_repos_src_path =
- svn_dirent_is_child(merge_b->target_abspath, child->abspath,
+ svn_dirent_is_child(merge_b->target->abspath, child->abspath,
iterpool);
/* This loop is only processing subtrees, so CHILD->ABSPATH
@@ -3371,16 +3439,13 @@ fix_deleted_subtree_ranges(const char *u
SVN_ERR_ASSERT(child_repos_src_path);
child_primary_source_url =
- svn_path_url_add_component2((revision1 < revision2) ? url2 : url1,
+ svn_path_url_add_component2((source->loc1->rev < source->loc2->rev)
+ ? source->loc2->url : source->loc1->url,
child_repos_src_path, iterpool);
- SVN_ERR(svn_ra__get_fspath_relative_to_root(ra_session,
- &child_mergeinfo_path,
- child_primary_source_url,
- iterpool));
SVN_ERR(adjust_deleted_subtree_ranges(child, parent,
- child_mergeinfo_path,
- revision1, revision2,
+ source->loc1->rev,
+ source->loc2->rev,
child_primary_source_url,
ra_session,
merge_b->ctx, result_pool,
@@ -3415,14 +3480,14 @@ fix_deleted_subtree_ranges(const char *u
INHERITED is ignored.
- If IMPLICIT_MERGEINFO is not NULL then START and END are limits on the
+ If IMPLICIT_MERGEINFO is not NULL then START and END are limits on
the natural history sought, must both be valid revision numbers, and
START must be greater than END. If TARGET_ABSPATH's base revision
is older than START, then the base revision is used as the younger
bound in place of START.
- RA_SESSION is an open session that may be temporarily reparented as
- needed by this function.
+ RA_SESSION is an RA session open to the repository in which TARGET_ABSPATH
+ lives. It may be temporarily reparented as needed by this function.
Allocate *RECORDED_MERGEINFO and *IMPLICIT_MERGEINFO in RESULT_POOL.
Use SCRATCH_POOL for any temporary allocations. */
@@ -3442,49 +3507,35 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
/* First, we get the real mergeinfo. */
if (recorded_mergeinfo)
{
- svn_boolean_t inherited_mergeinfo;
- svn_boolean_t inherited_from_repos;
-
SVN_ERR(svn_client__get_wc_or_repos_mergeinfo(recorded_mergeinfo,
- &inherited_mergeinfo,
- &inherited_from_repos,
+ inherited,
+ NULL /* from_repos */,
FALSE,
inherit, ra_session,
target_abspath,
ctx, result_pool));
- if (inherited)
- *inherited = inherited_mergeinfo;
}
if (implicit_mergeinfo)
{
- const char *repos_root;
- const char *repos_relpath;
- const char *session_url = NULL;
- svn_revnum_t target_rev;
+ svn_client__pathrev_t *target;
/* Assert that we have sane input. */
- SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(start)
- && SVN_IS_VALID_REVNUM(end)
- && (start > end));
+ SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(start) && SVN_IS_VALID_REVNUM(end)
+ && (start > end));
/* Retrieve the origin (original_*) of the node, or just the
url if the node was not copied. */
- SVN_ERR(svn_wc__node_get_origin(FALSE, &target_rev, &repos_relpath,
- &repos_root, 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(&target, target_abspath, ctx,
+ scratch_pool, scratch_pool));
+
+ if (! target)
+ {
+ /* 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)
+ else if (target->rev <= end)
{
/* We're asking about a range outside our natural history
altogether. That means our implicit mergeinfo is empty. */
@@ -3492,35 +3543,22 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
}
else
{
- const char *url;
-
- url = svn_path_url_add_component2(repos_root, repos_relpath,
- scratch_pool);
-
- /* Temporarily point our RA_SESSION at our target URL so we can
- fetch so-called "implicit mergeinfo" (that is, natural
+ /* Fetch so-called "implicit mergeinfo" (that is, natural
history). */
- SVN_ERR(svn_client__ensure_ra_session_url(&session_url,
- ra_session, url,
- scratch_pool));
/* Do not ask for implicit mergeinfo from TARGET_ABSPATH's future.
TARGET_ABSPATH might not even exist, and even if it does the
working copy is *at* TARGET_REV so its implicit history ends
at TARGET_REV! */
- if (target_rev < start)
- start = target_rev;
+ if (target->rev < start)
+ start = target->rev;
/* Fetch the implicit mergeinfo. */
SVN_ERR(svn_client__get_history_as_mergeinfo(implicit_mergeinfo,
NULL,
- target_rev,
- start, end,
+ target, start, end,
ra_session, ctx,
result_pool));
-
- /* Return RA_SESSION back to where it was when we were called. */
- SVN_ERR(svn_ra_reparent(ra_session, session_url, scratch_pool));
}
} /*if (implicit_mergeinfo) */
@@ -3529,7 +3567,7 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
/* Helper for ensure_implicit_mergeinfo().
- PARENT, CHILD, REVISION1, REVISION2, RA_SESSION, and CTX
+ PARENT, CHILD, REVISION1, REVISION2 and CTX
are all cascaded from the arguments of the same names in
ensure_implicit_mergeinfo(). PARENT and CHILD must both exist, i.e.
this function should never be called where CHILD is the merge target.
@@ -3539,6 +3577,9 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
Set CHILD->IMPLICIT_MERGEINFO to the mergeinfo inherited from
PARENT->IMPLICIT_MERGEINFO. CHILD->IMPLICIT_MERGEINFO is allocated
in RESULT_POOL.
+
+ RA_SESSION is an RA session open to the repository that contains CHILD.
+ It may be temporarily reparented by this function.
*/
static svn_error_t *
inherit_implicit_mergeinfo_from_parent(svn_client__merge_path_t *parent,
@@ -3586,11 +3627,14 @@ inherit_implicit_mergeinfo_from_parent(s
If we have deferred obtaining CHILD->IMPLICIT_MERGEINFO, then get
it now, allocating it in RESULT_POOL. If CHILD_INHERITS_PARENT is true
then set CHILD->IMPLICIT_MERGEINFO to the mergeinfo inherited from
- PARNET->IMPLICIT_MERGEINFO, otherwise contact the repository. Use
+ PARENT->IMPLICIT_MERGEINFO, otherwise contact the repository. Use
SCRATCH_POOL for all temporary allocations.
- PARENT, CHILD, REVISION1, REVISION2, RA_SESSION, and
- CTX are all cascased from the arguments of the same name in
+ RA_SESSION is an RA session open to the repository that contains CHILD.
+ It may be temporarily reparented by this function.
+
+ PARENT, CHILD, REVISION1, REVISION2 and
+ CTX are all cascaded from the arguments of the same name in
filter_merged_revisions() and the same conditions for that function
hold here. */
static svn_error_t *
@@ -3810,7 +3854,7 @@ filter_merged_revisions(svn_client__merg
else
target_rangelist = NULL;
- /* See earlier comment preceeding svn_rangelist_intersect() for
+ /* See earlier comment preceding svn_rangelist_intersect() for
why we don't consider inheritance here. */
if (target_rangelist)
{
@@ -3892,13 +3936,12 @@ filter_merged_revisions(svn_client__merg
/* Helper for do_file_merge and do_directory_merge (by way of
populate_remaining_ranges() for the latter).
- Determine what portions of URL1@REVISION1 -> URL2@REVISION2 have already
+ Determine what portions of SOURCE have already
been merged to CHILD->ABSPATH and populate CHILD->REMAINING_RANGES with
the ranges that still need merging.
- URL1, REVISION1, URL2, REVISION2, and CTX are all cascaded
- from the caller's arguments of the same names. Note that this means URL1,
- REVISION1, URL2, and REVISION2 adhere to the requirements noted in
+ SOURCE and CTX are all cascaded from the caller's arguments of the same
+ names. Note that this means SOURCE adheres to the requirements noted in
`MERGEINFO MERGE SOURCE NORMALIZATION'.
CHILD represents a working copy path which is the merge target or one of
@@ -3906,8 +3949,8 @@ filter_merged_revisions(svn_client__merg
ancestor - see 'THE CHILDREN_WITH_MERGEINFO ARRAY'. TARGET_MERGEINFO is
the working mergeinfo on CHILD.
- RA_SESSION is the session for the younger of URL1@REVISION1 and
- URL2@REVISION2.
+ RA_SESSION is the session for the younger of SOURCE->url1@rev1 and
+ SOURCE->url2@rev2.
If the function needs to consider CHILD->IMPLICIT_MERGEINFO and
CHILD_INHERITS_IMPLICIT is true, then set CHILD->IMPLICIT_MERGEINFO to the
@@ -3915,7 +3958,7 @@ filter_merged_revisions(svn_client__merg
the repository for CHILD->IMPLICIT_MERGEINFO.
If not null, IMPLICIT_SRC_GAP is the gap, if any, in the natural history
- of URL1@REVISION1:URL2@REVISION2, see merge_cmd_baton_t.implicit_src_gap.
+ of SOURCE, see merge_cmd_baton_t.implicit_src_gap.
SCRATCH_POOL is used for all temporary allocations. Changes to CHILD and
PARENT are made in RESULT_POOL.
@@ -3928,18 +3971,15 @@ filter_merged_revisions(svn_client__merg
in depth-first order.
NOTE: When performing reverse merges, return
- SVN_ERR_CLIENT_NOT_READY_TO_MERGE if URL1@REVISION1, URL2@REVISION2, and
+ SVN_ERR_CLIENT_NOT_READY_TO_MERGE if both locations in SOURCE and
CHILD->ABSPATH are all on the same line of history but CHILD->ABSPATH's
- base revision is older than the REVISION1-REVISION2 range, see comment re
+ base revision is older than the SOURCE->rev1:rev2 range, see comment re
issue #2973 below.
*/
static svn_error_t *
calculate_remaining_ranges(svn_client__merge_path_t *parent,
svn_client__merge_path_t *child,
- const char *url1,
- svn_revnum_t revision1,
- const char *url2,
- svn_revnum_t revision2,
+ const merge_source_t *source,
svn_mergeinfo_t target_mergeinfo,
const apr_array_header_t *implicit_src_gap,
svn_boolean_t child_inherits_implicit,
@@ -3949,7 +3989,8 @@ calculate_remaining_ranges(svn_client__m
apr_pool_t *scratch_pool)
{
const char *mergeinfo_path;
- const char *primary_url = (revision1 < revision2) ? url2 : url1;
+ const char *primary_url = (source->loc1->rev < source->loc2->rev)
+ ? source->loc2->url : source->loc1->url;
svn_mergeinfo_t adjusted_target_mergeinfo = NULL;
svn_revnum_t child_base_revision;
@@ -3958,10 +3999,10 @@ calculate_remaining_ranges(svn_client__m
primary_url, result_pool));
/* Consider: CHILD might have explicit mergeinfo '/MERGEINFO_PATH:M-N'
- where M-N fall into the gap in URL1@REVISION1:URL2@REVISION2's natural
+ where M-N fall into the gap in SOURCE's natural
history allowed by 'MERGEINFO MERGE SOURCE NORMALIZATION'. If this is
the case, then '/MERGEINFO_PATH:N' actually refers to a completely
- different line of history than URL1@REVISION1:URL2@REVISION2 and we
+ different line of history than SOURCE and we
*don't* want to consider those revisions merged already. */
if (implicit_src_gap && child->pre_merge_mergeinfo)
{
@@ -3989,7 +4030,7 @@ calculate_remaining_ranges(svn_client__m
merged (or, in the case of reverse merges, ranges not yet merged). */
SVN_ERR(filter_merged_revisions(parent, child, mergeinfo_path,
adjusted_target_mergeinfo,
- revision1, revision2,
+ source->loc1->rev, source->loc2->rev,
child_inherits_implicit,
ra_session, ctx, result_pool,
scratch_pool));
@@ -4026,23 +4067,19 @@ calculate_remaining_ranges(svn_client__m
can't have any "future" history. */
if (SVN_IS_VALID_REVNUM(child_base_revision)
&& ((child->remaining_ranges)->nelts == 0) /* Inoperative merge */
- && (revision2 < revision1) /* Reverse merge */
- && (child_base_revision <= revision2)) /* From CHILD's future */
+ && (source->loc2->rev < source->loc1->rev) /* Reverse merge */
+ && (child_base_revision <= source->loc2->rev)) /* From CHILD's future */
{
/* Hmmm, an inoperative reverse merge from the "future". If it is
from our own future return a helpful error. */
svn_error_t *err;
- const char *start_url;
- svn_opt_revision_t requested, pegrev;
- requested.kind = svn_opt_revision_number;
- requested.value.number = child_base_revision;
- pegrev.kind = svn_opt_revision_number;
- pegrev.value.number = revision1;
-
- err = svn_client__repos_locations(&start_url, NULL,
- NULL, NULL, ra_session, url1,
- &pegrev, &requested,
- NULL, ctx, scratch_pool);
+ svn_client__pathrev_t *start_loc;
+
+ err = svn_client__repos_location(&start_loc,
+ ra_session,
+ source->loc1,
+ child_base_revision,
+ ctx, scratch_pool, scratch_pool);
if (err)
{
if (err->apr_err == SVN_ERR_FS_NOT_FOUND
@@ -4057,7 +4094,7 @@ calculate_remaining_ranges(svn_client__m
SVN_ERR(svn_wc__node_get_url(&url, ctx->wc_ctx, child->abspath,
scratch_pool, scratch_pool));
- if (strcmp(start_url, url) == 0)
+ if (strcmp(start_loc->url, url) == 0)
return svn_error_create(SVN_ERR_CLIENT_MERGE_UPDATE_REQUIRED, NULL,
_("Cannot reverse-merge a range from a "
"path's own future history; try "
@@ -4070,58 +4107,59 @@ calculate_remaining_ranges(svn_client__m
/* Helper for populate_remaining_ranges().
- URL1, REVISION1, URL2, REVISION2, RA_SESSION, MERGE_SRC_CANON_PATH,
- and MERGE_B are all cascaded from the arguments of the same name in
- populate_remaining_ranges(). MERGE_SRC_CANON_PATH is the absolute
- repository path of URL2.
-
- Note: The following comments assume a forward merge, i.e.
- REVISION1 < REVISION2. If this is a reverse merge then all the following
- comments still apply, but with URL1 switched with URL2 and REVISION1
- switched with REVISION2.
-
- Like populate_remaining_ranges(), URL1@REVISION1:URL2@REVISION2 must adhere
- to the restrictions documented in 'MERGEINFO MERGE SOURCE NORMALIZATION'.
- These restrictions allow for a *single* gap, URL@GAP_REV1:URL2@GAP_REV2,
- (where REVISION1 < GAP_REV1 <= GAP_REV2 < REVISION2) in
- URL1@REVISION1:URL2@REVISION2 if URL2@REVISION2 was copied from
- URL1@REVISION1. If such a gap exists, set *GAP_START and *GAP_END to the
- starting and ending revisions of the gap. Otherwise set both to
- SVN_INVALID_REVNUM.
+ SOURCE and MERGE_B are cascaded from the arguments of the same name in
+ populate_remaining_ranges().
+
+ Note: The following comments assume a forward merge, i.e. SOURCE->rev1
+ < SOURCE->rev2. If this is a reverse merge then all the following
+ comments still apply, but with SOURCE->url1 switched with SOURCE->url2
+ and SOURCE->rev1 switched with SOURCE->rev2.
+
+ Like populate_remaining_ranges(), SOURCE must adhere to the restrictions
+ documented in 'MERGEINFO MERGE SOURCE NORMALIZATION'. These restrictions
+ allow for a *single* gap, URL@GAP_REV1:URL2@GAP_REV2, (where SOURCE->rev1
+ < GAP_REV1 <= GAP_REV2 < SOURCE->rev2) in SOURCE if SOURCE->url2@rev2 was
+ copied from SOURCE->url1@rev1. If such a gap exists, set *GAP_START and
+ *GAP_END to the starting and ending revisions of the gap. Otherwise set
+ both to SVN_INVALID_REVNUM.
For example, if the natural history of URL@2:URL@9 is 'trunk/:2,7-9' this
would indicate that trunk@7 was copied from trunk@2. This function would
return GAP_START:GAP_END of 2:6 in this case. Note that a path 'trunk'
might exist at r3-6, but it would not be on the same line of history as
- trunk@9. */
+ trunk@9.
+
+ RA_SESSION is an open RA session to the repository in which SOURCE lives.
+*/
static svn_error_t *
find_gaps_in_merge_source_history(svn_revnum_t *gap_start,
svn_revnum_t *gap_end,
- const char *merge_src_canon_path,
- const char *url1,
- svn_revnum_t revision1,
- const char *url2,
- svn_revnum_t revision2,
+ const merge_source_t *source,
svn_ra_session_t *ra_session,
merge_cmd_baton_t *merge_b,
apr_pool_t *scratch_pool)
{
svn_mergeinfo_t implicit_src_mergeinfo;
- svn_revnum_t young_rev = MAX(revision1, revision2);
- svn_revnum_t old_rev = MIN(revision1, revision2);
+ svn_revnum_t old_rev = MIN(source->loc1->rev, source->loc2->rev);
+ const svn_client__pathrev_t *primary_src
+ = (source->loc1->rev < source->loc2->rev) ? source->loc2 : source->loc1;
+ const char *merge_src_fspath;
apr_array_header_t *rangelist;
/* Start by assuming there is no gap. */
*gap_start = *gap_end = SVN_INVALID_REVNUM;
- /* Get URL1@REVISION1:URL2@REVISION2 as mergeinfo. */
+ /* Get SOURCE as mergeinfo. */
SVN_ERR(svn_client__get_history_as_mergeinfo(&implicit_src_mergeinfo, NULL,
- young_rev, young_rev,
- old_rev, ra_session,
+ primary_src,
+ primary_src->rev, old_rev,
+ ra_session,
merge_b->ctx, scratch_pool));
+ SVN_ERR(svn_ra__get_fspath_relative_to_root(
+ ra_session, &merge_src_fspath, primary_src->url, scratch_pool));
rangelist = apr_hash_get(implicit_src_mergeinfo,
- merge_src_canon_path,
+ merge_src_fspath,
APR_HASH_KEY_STRING);
if (!rangelist) /* ### Can we ever not find a rangelist? */
@@ -4154,7 +4192,7 @@ find_gaps_in_merge_source_history(svn_re
/* As mentioned above, multiple gaps *shouldn't* be possible. */
SVN_ERR_ASSERT(apr_hash_count(implicit_src_mergeinfo) == 1);
- *gap_start = MIN(revision1, revision2);
+ *gap_start = MIN(source->loc1->rev, source->loc2->rev);
*gap_end = (APR_ARRAY_IDX(rangelist,
rangelist->nelts - 1,
svn_merge_range_t *))->start;
@@ -4162,8 +4200,8 @@ find_gaps_in_merge_source_history(svn_re
else if (apr_hash_count(implicit_src_mergeinfo) > 1) /* Rename */
{
apr_array_header_t *requested_rangelist =
- svn_rangelist__initialize(MIN(revision1, revision2),
- MAX(revision1, revision2),
+ svn_rangelist__initialize(MIN(source->loc1->rev, source->loc2->rev),
+ MAX(source->loc1->rev, source->loc2->rev),
TRUE, scratch_pool);
apr_array_header_t *implicit_rangelist =
apr_array_make(scratch_pool, 2, sizeof(svn_merge_range_t *));
@@ -4192,35 +4230,34 @@ find_gaps_in_merge_source_history(svn_re
/* Helper for do_directory_merge().
- For each child in CHILDREN_WITH_MERGEINFO, populate that
- child's remaining_ranges list. CHILDREN_WITH_MERGEINFO is expected
+ For each (svn_client__merge_path_t *) child in CHILDREN_WITH_MERGEINFO,
+ populate that child's 'remaining_ranges' list with (### ... what?),
+ and populate that child's 'implicit_mergeinfo' with its implicit
+ mergeinfo (natural history). CHILDREN_WITH_MERGEINFO is expected
to be sorted in depth first order and each child must be processed in
that order. The inheritability of all calculated ranges is TRUE.
- If HONOR_MERGEINFO is set, this function will actually try to be
+ If mergeinfo is being honored (based on MERGE_B -- see HONOR_MERGEINFO()
+ for how this is determined), this function will actually try to be
intelligent about populating remaining_ranges list. Otherwise, it
will claim that each child has a single remaining range, from
- revision1, to revision2.
+ SOURCE->rev1, to SOURCE->rev2.
+ ### We also take the short-cut if doing record-only. Why?
SCRATCH_POOL is used for all temporary allocations. Changes to
CHILDREN_WITH_MERGEINFO are made in RESULT_POOL.
- Note that if REVISION1 > REVISION2, then each child's remaining_ranges
+ Note that if SOURCE->rev1 > SOURCE->rev2, then each child's remaining_ranges
member does not adhere to the API rules for rangelists described in
svn_mergeinfo.h -- See svn_client__merge_path_t.
See `MERGEINFO MERGE SOURCE NORMALIZATION' for more requirements
- around the values of URL1, REVISION1, URL2, and REVISION2.
+ around SOURCE.
*/
static svn_error_t *
populate_remaining_ranges(apr_array_header_t *children_with_mergeinfo,
- const char *url1,
- svn_revnum_t revision1,
- const char *url2,
- svn_revnum_t revision2,
- svn_boolean_t honor_mergeinfo,
+ const merge_source_t *source,
svn_ra_session_t *ra_session,
- const char *parent_merge_src_canon_path,
merge_cmd_baton_t *merge_b,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
@@ -4230,9 +4267,9 @@ populate_remaining_ranges(apr_array_head
svn_revnum_t gap_start, gap_end;
/* If we aren't honoring mergeinfo or this is a --record-only merge,
- we'll make quick work of this by simply adding dummy REVISION1:REVISION2
+ we'll make quick work of this by simply adding dummy SOURCE->rev1:rev2
ranges for all children. */
- if (! honor_mergeinfo || merge_b->record_only)
+ if (! HONOR_MERGEINFO(merge_b) || merge_b->record_only)
{
for (i = 0; i < children_with_mergeinfo->nelts; i++)
{
@@ -4253,8 +4290,10 @@ populate_remaining_ranges(apr_array_head
NULL, /* child->inherited_mergeinfo */
svn_mergeinfo_inherited, ra_session,
child->abspath,
- MAX(revision1, revision2),
- MIN(revision1, revision2),
+ MAX(source->loc1->rev,
+ source->loc2->rev),
+ MIN(source->loc1->rev,
+ source->loc2->rev),
merge_b->ctx, result_pool,
iterpool));
}
@@ -4262,11 +4301,9 @@ populate_remaining_ranges(apr_array_head
{
/* Issue #3443 - Subtrees of the merge target can inherit
their parent's implicit mergeinfo in most cases. */
- int parent_index = find_nearest_ancestor(children_with_mergeinfo,
- FALSE, child->abspath);
svn_client__merge_path_t *parent
- = APR_ARRAY_IDX(children_with_mergeinfo, parent_index,
- svn_client__merge_path_t *);
+ = find_nearest_ancestor(children_with_mergeinfo,
+ FALSE, child->abspath);
svn_boolean_t child_inherits_implicit;
/* If CHILD is a subtree then its parent must be in
@@ -4277,13 +4314,14 @@ populate_remaining_ranges(apr_array_head
child_inherits_implicit = (parent && !child->switched);
SVN_ERR(ensure_implicit_mergeinfo(parent, child,
child_inherits_implicit,
- revision1, revision2,
+ source->loc1->rev,
+ source->loc2->rev,
ra_session, merge_b->ctx,
result_pool, iterpool));
}
- child->remaining_ranges = svn_rangelist__initialize(revision1,
- revision2,
+ child->remaining_ranges = svn_rangelist__initialize(source->loc1->rev,
+ source->loc2->rev,
TRUE,
result_pool);
}
@@ -4292,21 +4330,19 @@ populate_remaining_ranges(apr_array_head
}
/* If, in the merge source's history, there was a copy from a older
- revision, then URL2 won't exist at some range M:N, where
- REVISION1 < M < N < REVISION2. The rules of 'MERGEINFO MERGE SOURCE
- NORMALIZATION' allow this, but we must ignore these gaps when
- calculating what ranges remain to be merged from
- URL1@REVISION1:URL2@REVISION2. If we don't and try to merge any part
- of URL2@M:URL2@N we would break the editor since no part of that
- actually exists. See http://svn.haxx.se/dev/archive-2008-11/0618.shtml.
+ revision, then SOURCE->url2 won't exist at some range M:N, where
+ source->rev1 < M < N < source->rev2. The rules of 'MERGEINFO MERGE
+ SOURCE NORMALIZATION' allow this, but we must ignore these gaps when
+ calculating what ranges remain to be merged from SOURCE. If we don't
+ and try to merge any part of SOURCE->url2@M:N we would break the
+ editor since no part of that actually exists. See
+ http://svn.haxx.se/dev/archive-2008-11/0618.shtml.
Find the gaps in the merge target's history, if any. Eventually
we will adjust CHILD->REMAINING_RANGES such that we don't describe
non-existent paths to the editor. */
SVN_ERR(find_gaps_in_merge_source_history(&gap_start, &gap_end,
- parent_merge_src_canon_path,
- url1, revision1,
- url2, revision2,
+ source,
ra_session, merge_b,
iterpool));
@@ -4319,7 +4355,9 @@ populate_remaining_ranges(apr_array_head
for (i = 0; i < children_with_mergeinfo->nelts; i++)
{
const char *child_repos_path;
- const char *child_url1, *child_url2;
+ svn_client__pathrev_t loc1 = *source->loc1;
+ svn_client__pathrev_t loc2 = *source->loc2;
+ merge_source_t child_source = { &loc1, &loc2 };
svn_client__merge_path_t *child =
APR_ARRAY_IDX(children_with_mergeinfo, i, svn_client__merge_path_t *);
svn_client__merge_path_t *parent = NULL;
@@ -4334,13 +4372,13 @@ populate_remaining_ranges(apr_array_head
svn_pool_clear(iterpool);
- child_repos_path = svn_dirent_skip_ancestor(merge_b->target_abspath,
+ child_repos_path = svn_dirent_skip_ancestor(merge_b->target->abspath,
child->abspath);
SVN_ERR_ASSERT(child_repos_path != NULL);
- child_url1 = svn_path_url_add_component2(url1, child_repos_path,
- iterpool);
- child_url2 = svn_path_url_add_component2(url2, child_repos_path,
- iterpool);
+ loc1.url = svn_path_url_add_component2(
+ source->loc1->url, child_repos_path, iterpool);
+ loc2.url = svn_path_url_add_component2(
+ source->loc2->url, child_repos_path, iterpool);
/* Get the explicit/inherited mergeinfo for CHILD. If CHILD is the
merge target then also get its implicit mergeinfo. Otherwise defer
@@ -4353,17 +4391,15 @@ populate_remaining_ranges(apr_array_head
&(child->inherited_mergeinfo),
svn_mergeinfo_inherited, ra_session,
child->abspath,
- MAX(revision1, revision2),
- MIN(revision1, revision2),
+ MAX(source->loc1->rev, source->loc2->rev),
+ MIN(source->loc1->rev, source->loc2->rev),
merge_b->ctx, result_pool, iterpool));
/* If CHILD isn't the merge target find its parent. */
if (i > 0)
{
- int parent_index = find_nearest_ancestor(children_with_mergeinfo,
- FALSE, child->abspath);
- parent = APR_ARRAY_IDX(children_with_mergeinfo, parent_index,
- svn_client__merge_path_t *);
+ parent = find_nearest_ancestor(children_with_mergeinfo,
+ FALSE, child->abspath);
/* If CHILD is a subtree then its parent must be in
CHILDREN_WITH_MERGEINFO, see the global comment
'THE CHILDREN_WITH_MERGEINFO ARRAY'. */
@@ -4378,8 +4414,7 @@ populate_remaining_ranges(apr_array_head
child_inherits_implicit = (parent && !child->switched);
SVN_ERR(calculate_remaining_ranges(parent, child,
- child_url1, revision1,
- child_url2, revision2,
+ &child_source,
child->pre_merge_mergeinfo,
merge_b->implicit_src_gap,
child_inherits_implicit,
@@ -4387,7 +4422,7 @@ populate_remaining_ranges(apr_array_head
merge_b->ctx, result_pool,
iterpool));
- /* Deal with any gap in URL1@REVISION1:URL2@REVISION2's natural history.
+ /* Deal with any gap in SOURCE's natural history.
If the gap is a proper subset of CHILD->REMAINING_RANGES then we can
safely ignore it since we won't describe this path/rev pair.
@@ -4403,32 +4438,31 @@ populate_remaining_ranges(apr_array_head
&& merge_b->implicit_src_gap)
{
int j;
- svn_revnum_t start, end;
svn_boolean_t proper_subset = FALSE;
svn_boolean_t overlaps_or_adjoins = FALSE;
/* If this is a reverse merge reorder CHILD->REMAINING_RANGES
so it will work with the svn_rangelist_* APIs below. */
- if (revision1 > revision2)
+ if (source->loc1->rev > source->loc2->rev)
SVN_ERR(svn_rangelist_reverse(child->remaining_ranges, iterpool));
for (j = 0; j < child->remaining_ranges->nelts; j++)
{
- start = (APR_ARRAY_IDX(child->remaining_ranges, j,
- svn_merge_range_t *))->start;
- end = (APR_ARRAY_IDX(child->remaining_ranges, j,
- svn_merge_range_t *))->end;
- if ((start <= gap_start && gap_end < end)
- || (start < gap_start && gap_end <= end))
+ svn_merge_range_t *range
+ = APR_ARRAY_IDX(child->remaining_ranges, j, svn_merge_range_t *);
+
+ if ((range->start <= gap_start && gap_end < range->end)
+ || (range->start < gap_start && gap_end <= range->end))
{
proper_subset = TRUE;
break;
}
- else if ((gap_start == start) && (end == gap_end))
+ else if ((gap_start == range->start) && (range->end == gap_end))
{
break;
}
- else if (gap_start <= end && start <= gap_end) /* intersect */
+ else if (gap_start <= range->end && range->start <= gap_end)
+ /* intersect */
{
overlaps_or_adjoins = TRUE;
break;
@@ -4437,7 +4471,7 @@ populate_remaining_ranges(apr_array_head
if (!proper_subset)
{
- /* We need to make adjustements. Remove from, or add the gap
[... 6831 lines stripped ...]