You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2011/12/18 18:36:29 UTC
svn commit: r1220465 [4/13] - in /subversion/branches/file-handle-cache: ./
build/ build/ac-macros/ contrib/client-side/emacs/
contrib/server-side/mod_dontdothat/ notes/
subversion/bindings/javahl/tests/org/apache/subversion/javahl/
subversion/bindings...
Modified: subversion/branches/file-handle-cache/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/branches/file-handle-cache/subversion/libsvn_client/merge.c?rev=1220465&r1=1220464&r2=1220465&view=diff
==============================================================================
--- subversion/branches/file-handle-cache/subversion/libsvn_client/merge.c (original)
+++ subversion/branches/file-handle-cache/subversion/libsvn_client/merge.c Sun Dec 18 17:36:24 2011
@@ -52,9 +52,11 @@
#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 "svn_private_config.h"
@@ -292,6 +294,13 @@ 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 SVN_ERR_UNSUPPORTED_FEATURE if URL is not inside the repository
of LOCAL_ABSPATH. Use SCRATCH_POOL for temporary allocations. */
static svn_error_t *
@@ -309,6 +318,42 @@ check_repos_match(merge_cmd_baton_t *mer
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
+ * 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,
+ 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);
+ else
+ return (strcmp(repos_root1->uuid, repos_root2->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
+ * 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,
+ const char *path1,
+ const url_uuid_t *repos_root2,
+ const char *path2,
+ svn_boolean_t strict_urls,
+ apr_pool_t *scratch_pool)
+{
+ if (! is_same_repos(repos_root1, repos_root2, strict_urls))
+ return svn_error_createf(SVN_ERR_CLIENT_UNRELATED_RESOURCES, NULL,
+ _("'%s' must be from the same repository as "
+ "'%s'"), path1, path2);
+ return SVN_NO_ERROR;
+}
+
/* Return true iff we're in dry-run mode and WCPATH would have been
deleted by now if we weren't in dry-run mode.
Used to avoid spurious notifications (e.g. conflicts) from a merge
@@ -468,12 +513,12 @@ make_conflict_versions(const svn_wc_conf
*left = svn_wc_conflict_version_create(
src_repos_url,
- svn_uri__is_child(src_repos_url, left_url, merge_b->pool),
+ svn_uri_skip_ancestor(src_repos_url, left_url, merge_b->pool),
merge_b->merge_source.rev1, node_kind, merge_b->pool);
*right = svn_wc_conflict_version_create(
src_repos_url,
- svn_uri__is_child(src_repos_url, right_url, merge_b->pool),
+ svn_uri_skip_ancestor(src_repos_url, right_url, merge_b->pool),
merge_b->merge_source.rev2, node_kind, merge_b->pool);
return SVN_NO_ERROR;
@@ -547,6 +592,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);
@@ -588,6 +634,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);
@@ -618,6 +665,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);
@@ -746,7 +794,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).
@@ -755,14 +803,14 @@ 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.
@@ -771,9 +819,9 @@ omit_mergeinfo_changes(apr_array_header_
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,
@@ -785,7 +833,8 @@ filter_self_referential_mergeinfo(apr_ar
int i;
apr_pool_t *iterpool;
svn_boolean_t is_added;
- svn_revnum_t base_revision;
+ const char *target_base_url;
+ svn_revnum_t target_base_rev;
/* Issue #3383: We don't want mergeinfo from a foreign repos.
@@ -809,12 +858,14 @@ 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_client_url_from_path2(&target_base_url, target_abspath,
+ ctx, pool, pool));
+ SVN_ERR(svn_wc__node_get_base_rev(&target_base_rev, ctx->wc_ctx,
+ target_abspath, pool));
adjusted_props = apr_array_make(pool, (*props)->nelts, sizeof(svn_prop_t));
iterpool = svn_pool_create(pool);
@@ -825,7 +876,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;
@@ -842,11 +892,9 @@ filter_self_referential_mergeinfo(apr_ar
/* 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));
+ target_base_url, iterpool));
/* Parse the incoming mergeinfo to allow easier manipulation. */
err = svn_mergeinfo_parse(&mergeinfo, prop->value->data, iterpool);
@@ -899,7 +947,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. */
@@ -928,38 +976,22 @@ filter_self_referential_mergeinfo(apr_ar
for (j = 0; j < rangelist->nelts; j++)
{
svn_error_t *err2;
- svn_opt_revision_t *start_revision;
const char *start_url;
- svn_opt_revision_t peg_rev, rev1_opt;
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,
- &start_revision,
- 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_url, ra_session,
+ target_base_url, target_base_rev,
+ range->start + 1,
+ ctx, iterpool, iterpool);
if (err2)
{
if (err2->apr_err == SVN_ERR_CLIENT_UNRELATED_RESOURCES
@@ -1034,7 +1066,7 @@ filter_self_referential_mergeinfo(apr_ar
SVN_ERR(svn_client__get_history_as_mergeinfo(
&implicit_mergeinfo, NULL,
- base_revision, base_revision, SVN_INVALID_REVNUM,
+ target_base_rev, target_base_rev, SVN_INVALID_REVNUM,
ra_session,
ctx,
iterpool));
@@ -1173,8 +1205,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)
@@ -1221,6 +1254,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;
}
@@ -1280,8 +1315,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;
@@ -1429,6 +1464,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;
@@ -1659,6 +1697,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)
{
@@ -1946,9 +1987,7 @@ 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,
@@ -1985,6 +2024,9 @@ merge_file_deleted(svn_wc_notify_state_t
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);
@@ -2600,9 +2642,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;
@@ -2636,15 +2675,15 @@ typedef struct notification_receiver_bat
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;
@@ -2656,22 +2695,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 =
@@ -2679,12 +2713,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 \
@@ -2695,13 +2803,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
@@ -2709,15 +2830,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. */
@@ -2754,6 +2872,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)
{
@@ -2815,6 +2934,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;
@@ -2825,11 +2947,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)
{
@@ -2848,36 +2970,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);
}
}
}
@@ -2887,16 +2995,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)
@@ -3045,22 +3145,14 @@ adjust_deleted_subtree_ranges(svn_client
svn_revnum_t older_rev = is_rollback ? revision2 : revision1;
apr_array_header_t *segments;
const char *rel_source_path;
- const char *session_url;
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_session_url(ra_session, &session_url, scratch_pool));
- SVN_ERR(svn_client__path_relative_to_root(&rel_source_path,
- ctx->wc_ctx,
- primary_url,
- session_url,
- FALSE,
- ra_session,
- scratch_pool,
- scratch_pool));
+ 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,
younger_rev, older_rev, ctx,
@@ -3232,47 +3324,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;
- const char *source_root_url;
apr_pool_t *iterpool = svn_pool_create(scratch_pool);
- svn_boolean_t is_rollback = revision2 < revision1;
-
- SVN_ERR(svn_ra_get_repos_root2(ra_session, &source_root_url, scratch_pool));
+ svn_boolean_t is_rollback = source->rev2 < source->rev1;
- /* 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)
@@ -3281,10 +3364,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
@@ -3310,16 +3391,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
@@ -3341,18 +3421,17 @@ 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->rev1 < source->rev2)
+ ? source->url2 : source->url1,
child_repos_src_path, iterpool);
- SVN_ERR(svn_client__path_relative_to_root(&child_mergeinfo_path,
- merge_b->ctx->wc_ctx,
- child_primary_source_url,
- source_root_url,
- TRUE, ra_session,
- iterpool, 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->rev1, source->rev2,
child_primary_source_url,
ra_session,
merge_b->ctx, result_pool,
@@ -3414,18 +3493,15 @@ 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,
&inherited_from_repos,
FALSE,
inherit, ra_session,
target_abspath,
ctx, result_pool));
- if (inherited)
- *inherited = inherited_mergeinfo;
}
if (implicit_mergeinfo)
@@ -3562,7 +3638,7 @@ inherit_implicit_mergeinfo_from_parent(s
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
+ 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 *
@@ -3864,13 +3940,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
@@ -3878,8 +3953,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, and SOURCE_ROOT_URL is the repository root
- 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
@@ -3887,7 +3962,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.
@@ -3900,19 +3975,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 *source_root_url,
- 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,
@@ -3922,21 +3993,20 @@ 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->rev1 < source->rev2)
+ ? source->url2 : source->url1;
svn_mergeinfo_t adjusted_target_mergeinfo = NULL;
svn_revnum_t child_base_revision;
/* Determine which of the requested ranges to consider merging... */
- SVN_ERR(svn_client__path_relative_to_root(&mergeinfo_path, ctx->wc_ctx,
- primary_url, source_root_url, TRUE,
- ra_session, result_pool,
- scratch_pool));
+ SVN_ERR(svn_ra__get_fspath_relative_to_root(ra_session, &mergeinfo_path,
+ 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)
{
@@ -3964,7 +4034,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->rev1, source->rev2,
child_inherits_implicit,
ra_session, ctx, result_pool,
scratch_pool));
@@ -4001,23 +4071,18 @@ 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->rev2 < source->rev1) /* Reverse merge */
+ && (child_base_revision <= source->rev2)) /* 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, *start_revision;
- 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, &start_revision,
- NULL, NULL, ra_session, url1,
- &pegrev, &requested,
- NULL, ctx, scratch_pool);
+
+ err = svn_client__repos_location(&start_url,
+ ra_session, source->url1, source->rev1,
+ child_base_revision,
+ ctx, scratch_pool, scratch_pool);
if (err)
{
if (err->apr_err == SVN_ERR_FS_NOT_FOUND
@@ -4045,24 +4110,23 @@ calculate_remaining_ranges(svn_client__m
/* Helper for populate_remaining_ranges().
- URL1, REVISION1, URL2, REVISION2, RA_SESSION, MERGE_SRC_CANON_PATH,
+ SOURCE, 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.
+ repository path of SOURCE->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.
+ 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
@@ -4073,23 +4137,20 @@ 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 young_rev = MAX(source->rev1, source->rev2);
+ svn_revnum_t old_rev = MIN(source->rev1, source->rev2);
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,
@@ -4129,7 +4190,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->rev1, source->rev2);
*gap_end = (APR_ARRAY_IDX(rangelist,
rangelist->nelts - 1,
svn_merge_range_t *))->start;
@@ -4137,8 +4198,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->rev1, source->rev2),
+ MAX(source->rev1, source->rev2),
TRUE, scratch_pool);
apr_array_header_t *implicit_rangelist =
apr_array_make(scratch_pool, 2, sizeof(svn_merge_range_t *));
@@ -4175,25 +4236,21 @@ find_gaps_in_merge_source_history(svn_re
If HONOR_MERGEINFO is set, 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.
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 *source_root_url,
- const char *url1,
- svn_revnum_t revision1,
- const char *url2,
- svn_revnum_t revision2,
+ const merge_source_t *source,
svn_boolean_t honor_mergeinfo,
svn_ra_session_t *ra_session,
const char *parent_merge_src_canon_path,
@@ -4206,7 +4263,7 @@ 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)
{
@@ -4229,8 +4286,8 @@ 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->rev1, source->rev2),
+ MIN(source->rev1, source->rev2),
merge_b->ctx, result_pool,
iterpool));
}
@@ -4238,11 +4295,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
@@ -4253,13 +4308,13 @@ 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->rev1, source->rev2,
ra_session, merge_b->ctx,
result_pool, iterpool));
}
- child->remaining_ranges = svn_rangelist__initialize(revision1,
- revision2,
+ child->remaining_ranges = svn_rangelist__initialize(source->rev1,
+ source->rev2,
TRUE,
result_pool);
}
@@ -4268,21 +4323,20 @@ 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));
@@ -4295,7 +4349,7 @@ 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;
+ merge_source_t child_source = *source;
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;
@@ -4313,10 +4367,10 @@ populate_remaining_ranges(apr_array_head
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);
+ child_source.url1 = svn_path_url_add_component2(source->url1, child_repos_path,
+ iterpool);
+ child_source.url2 = svn_path_url_add_component2(source->url2, 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
@@ -4329,17 +4383,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->rev1, source->rev2),
+ MIN(source->rev1, source->rev2),
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'. */
@@ -4354,9 +4406,7 @@ populate_remaining_ranges(apr_array_head
child_inherits_implicit = (parent && !child->switched);
SVN_ERR(calculate_remaining_ranges(parent, child,
- source_root_url,
- child_url1, revision1,
- child_url2, revision2,
+ &child_source,
child->pre_merge_mergeinfo,
merge_b->implicit_src_gap,
child_inherits_implicit,
@@ -4364,7 +4414,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.
@@ -4380,32 +4430,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->rev1 > source->rev2)
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;
@@ -4428,7 +4477,7 @@ populate_remaining_ranges(apr_array_head
result_pool));
}
- if (revision1 > revision2) /* Reverse merge */
+ if (source->rev1 > source->rev2) /* Reverse merge */
SVN_ERR(svn_rangelist_reverse(child->remaining_ranges, iterpool));
}
}
@@ -4442,76 +4491,6 @@ populate_remaining_ranges(apr_array_head
/*** Other Helper Functions ***/
-/* Helper for record_mergeinfo_for_dir_merge().
-
- Adjust, in place, the inheritability of the ranges in RANGELIST to
- describe a merge of RANGELIST into WC_WCPATH at depth DEPTH. Set
- *RANGELIST_INHERITANCE to the inheritability set.
-
- WC_PATH_IS_MERGE_TARGET is true if WC_PATH is the target of the merge,
- otherwise WC_PATH is a subtree.
-
- WC_PATH_HAS_MISSING_CHILD is true if WC_PATH is missing an immediate child
- because the child is switched or absent from the WC, or due to a sparse
- checkout -- see get_mergeinfo_paths().
-
- Perform any temporary allocations in SCRATCH_POOL. */
-static svn_error_t *
-calculate_merge_inheritance(apr_array_header_t *rangelist,
- svn_boolean_t *rangelist_inheritance,
- const char *local_abspath,
- svn_boolean_t wc_path_is_merge_target,
- svn_boolean_t wc_path_has_missing_child,
- svn_depth_t depth,
- svn_wc_context_t *wc_ctx,
- apr_pool_t * scratch_pool)
-{
- svn_node_kind_t path_kind;
-
- SVN_ERR(svn_wc_read_kind(&path_kind, wc_ctx, local_abspath, FALSE,
- scratch_pool));
-
- /* Starting assumption. */
- *rangelist_inheritance = TRUE;
-
- if (path_kind == svn_node_file)
- {
- /* Files *never* have non-inheritable mergeinfo. */
- svn_rangelist__set_inheritance(rangelist, TRUE);
- }
- else if (path_kind == svn_node_dir)
- {
- if (wc_path_is_merge_target)
- {
- if (wc_path_has_missing_child
- || depth == svn_depth_files
- || depth == svn_depth_empty)
- {
- svn_rangelist__set_inheritance(rangelist, FALSE);
- *rangelist_inheritance = FALSE;
- }
- else /* depth == svn_depth_files || depth == svn_depth_empty */
- {
- svn_rangelist__set_inheritance(rangelist, TRUE);
- }
- }
- else /* WC_PATH is a directory subtree of the target. */
- {
- if (wc_path_has_missing_child
- || depth == svn_depth_immediates)
- {
- svn_rangelist__set_inheritance(rangelist, FALSE);
- *rangelist_inheritance = FALSE;
- }
- else /* depth == infinity */
- {
- svn_rangelist__set_inheritance(rangelist, TRUE);
- }
- }
- }
- return SVN_NO_ERROR;
-}
-
/* Calculate the new mergeinfo for the target tree rooted at TARGET_ABSPATH
based on MERGES (a mapping of absolute WC paths to rangelists representing
a merge from the source SOURCE_FSPATH).
@@ -4577,8 +4556,7 @@ update_wc_mergeinfo(svn_mergeinfo_catalo
mergeinfo that path inherits. */
if (mergeinfo == NULL && ranges->nelts == 0)
{
- svn_boolean_t inherited;
- SVN_ERR(svn_client__get_wc_mergeinfo(&mergeinfo, &inherited,
+ SVN_ERR(svn_client__get_wc_mergeinfo(&mergeinfo, NULL,
svn_mergeinfo_nearest_ancestor,
local_abspath, NULL, NULL,
FALSE, ctx, iterpool, iterpool));
@@ -4663,11 +4641,11 @@ update_wc_mergeinfo(svn_mergeinfo_catalo
Record override mergeinfo on any paths skipped during a merge.
- Set empty mergeinfo on each path in NOTIFY_B->SKIPPED_PATHS so the path
+ Set empty mergeinfo on each path in SKIPPED_ABSPATHS so the path
does not incorrectly inherit mergeinfo that will later be describing
the merge.
- MERGEINFO_PATH, NOTIFY_B, and MERGE_B are all cascased from
+ MERGEINFO_PATH and MERGE_B are cascaded from
arguments of the same name in the caller.
IS_ROLLBACK is true if the caller is recording a reverse merge and false
@@ -4677,14 +4655,14 @@ static svn_error_t *
record_skips(const char *mergeinfo_path,
const apr_array_header_t *rangelist,
svn_boolean_t is_rollback,
- notification_receiver_baton_t *notify_b,
+ apr_hash_t *skipped_abspaths,
merge_cmd_baton_t *merge_b,
apr_pool_t *scratch_pool)
{
apr_hash_index_t *hi;
apr_hash_t *merges;
- apr_size_t nbr_skips = (notify_b->skipped_abspaths != NULL ?
- apr_hash_count(notify_b->skipped_abspaths) : 0);
+ apr_size_t nbr_skips = (skipped_abspaths != NULL ?
+ apr_hash_count(skipped_abspaths) : 0);
apr_pool_t *iterpool = svn_pool_create(scratch_pool);
if (nbr_skips == 0)
@@ -4693,7 +4671,7 @@ record_skips(const char *mergeinfo_path,
merges = apr_hash_make(scratch_pool);
/* Override the mergeinfo for child paths which weren't actually merged. */
- for (hi = apr_hash_first(scratch_pool, notify_b->skipped_abspaths); hi;
+ for (hi = apr_hash_first(scratch_pool, skipped_abspaths); hi;
hi = apr_hash_next(hi))
{
const char *skipped_abspath = svn__apr_hash_index_key(hi);
@@ -4727,11 +4705,10 @@ record_skips(const char *mergeinfo_path,
apr_array_make(scratch_pool, 0,
sizeof(svn_merge_range_t *)));
- if (nbr_skips < notify_b->nbr_notifications)
- /* ### Use RANGELIST as the mergeinfo for all children of
+ /* if (nbr_skips < notify_b->nbr_notifications)
+ ### Use RANGELIST as the mergeinfo for all children of
### this path which were not also explicitly
### skipped? */
- ;
}
SVN_ERR(update_wc_mergeinfo(NULL, merge_b->target_abspath,
mergeinfo_path, merges,
@@ -4766,8 +4743,7 @@ make_merge_conflict_error(const char *ta
or are descendants of TARGET_WCPATH by setting those children to NULL. */
static void
remove_absent_children(const char *target_wcpath,
- apr_array_header_t *children_with_mergeinfo,
- notification_receiver_baton_t *notify_b)
+ apr_array_header_t *children_with_mergeinfo)
{
/* Before we try to override mergeinfo for skipped paths, make sure
the path isn't absent due to authz restrictions, because there's
@@ -4776,8 +4752,7 @@ remove_absent_children(const char *targe
for (i = 0; i < children_with_mergeinfo->nelts; i++)
{
svn_client__merge_path_t *child =
- APR_ARRAY_IDX(children_with_mergeinfo,
- i, svn_client__merge_path_t *);
+ APR_ARRAY_IDX(children_with_mergeinfo, i, svn_client__merge_path_t *);
if ((child->absent || child->scheduled_for_deletion)
&& svn_dirent_is_ancestor(target_wcpath, child->abspath))
{
@@ -4786,51 +4761,48 @@ remove_absent_children(const char *targe
}
}
-/* Helper for do_directory_merge() to handle the case were a merge editor
+/* Helper for do_directory_merge() to handle the case where a merge editor
drive removes explicit mergeinfo from a subtree of the merge target.
- MERGE_B, NOTIFY_B are cascaded from the arguments of the same name in
+ MERGE_B is cascaded from the argument of the same name in
do_directory_merge(). If MERGE_B->DRY_RUN is true do nothing, if it is
false then for each path (if any) in MERGE_B->PATHS_WITH_DELETED_MERGEINFO
- remove that path from NOTIFY_B->CHILDREN_WITH_MERGEINFO by setting that
+ remove that path from CHILDREN_WITH_MERGEINFO by setting that
child to NULL. The one exception is for the merge target itself,
MERGE_B->TARGET_ABSPATH, this must always be present in
- NOTIFY_B->CHILDREN_WITH_MERGEINFO so this is never removed by this
+ CHILDREN_WITH_MERGEINFO so this is never removed by this
function. */
static void
remove_children_with_deleted_mergeinfo(merge_cmd_baton_t *merge_b,
- notification_receiver_baton_t *notify_b)
+ apr_array_header_t *children_with_mergeinfo)
{
int i;
if (merge_b->dry_run || !merge_b->paths_with_deleted_mergeinfo)
return;
- /* NOTIFY_B->CHILDREN_WITH_MERGEINFO[0] is the always the merge target
+ /* CHILDREN_WITH_MERGEINFO[0] is the always the merge target
so start at the first child. */
- 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 *);
if (apr_hash_get(merge_b->paths_with_deleted_mergeinfo,
- child->abspath,
- APR_HASH_KEY_STRING))
+ child->abspath, APR_HASH_KEY_STRING))
{
- svn_sort__array_delete(notify_b->children_with_mergeinfo, i--, 1);
+ svn_sort__array_delete(children_with_mergeinfo, i--, 1);
}
}
}
/* Helper for do_directory_merge().
- Set up the diff editor report to merge URL1@REVISION1 to URL2@REVISION2
+ Set up the diff editor report to merge the SOURCE diff
into TARGET_ABSPATH and drive it.
If mergeinfo is not being honored based on MERGE_B, see the doc string for
HONOR_MERGEINFO() for how this is determined, then ignore
- CHILDREN_WITH_MERGEINFO and merge the diff between URL1@REVISION1 and
- URL2@REVISION2 to TARGET_ABSPATH.
+ CHILDREN_WITH_MERGEINFO and merge the SOURCE diff to TARGET_ABSPATH.
If mergeinfo is being honored then perform a history-aware merge,
describing TARGET_ABSPATH and its subtrees to the reporter in such as way
@@ -4842,36 +4814,36 @@ remove_children_with_deleted_mergeinfo(m
svn_client__merge_path_t * -- see 'THE CHILDREN_WITH_MERGEINFO ARRAY'
comment at the top of this file for more info. Note that it is possible
TARGET_ABSPATH and/or some of its subtrees need only a subset, or no part,
- of REVISION1:REVISION2 to be merged. Though there is little point to
+ of SOURCE to be merged. Though there is little point to
calling this function if TARGET_ABSPATH and all its subtrees have already
- had URL1@REVISION1 to URL2@REVISION2 merged, this will work but is a no-op.
+ had SOURCE merged, this will work but is a no-op.
- REVISION1 and REVISION2 must be bound by the set of remaining_ranges
+ SOURCE->rev1 and SOURCE->rev2 must be bound by the set of remaining_ranges
fields in CHILDREN_WITH_MERGEINFO's elements, specifically:
- For forward merges (REVISION1 < REVISION2):
+ For forward merges (SOURCE->rev1 < SOURCE->rev2):
1) The first svn_merge_range_t * element of each child's remaining_ranges
array must meet one of the following conditions:
- a) The range's start field is greater than or equal to REVISION2.
+ a) The range's start field is greater than or equal to SOURCE->rev2.
- b) The range's end field is REVISION2.
+ b) The range's end field is SOURCE->rev2.
2) Among all the ranges that meet condition 'b' the oldest start
- revision must equal REVISION1.
+ revision must equal SOURCE->rev1.
- For reverse merges (REVISION1 > REVISION2):
+ For reverse merges (SOURCE->rev1 > SOURCE->rev2):
1) The first svn_merge_range_t * element of each child's remaining_ranges
array must meet one of the following conditions:
- a) The range's start field is less than or equal to REVISION2.
+ a) The range's start field is less than or equal to SOURCE->rev2.
- b) The range's end field is REVISION2.
+ b) The range's end field is SOURCE->rev2.
2) Among all the ranges that meet condition 'b' the youngest start
- revision must equal REVISION1.
+ revision must equal SOURCE->rev1.
Note: If the first svn_merge_range_t * element of some subtree child's
remaining_ranges array is the same as the first range of that child's
@@ -4881,17 +4853,14 @@ remove_children_with_deleted_mergeinfo(m
DEPTH, NOTIFY_B, and MERGE_B are cascasded from do_directory_merge(), see
that function for more info.
- If MERGE_B->sources_ancestral is set, then URL1@REVISION1 must be a
- historical ancestor of URL2@REVISION2, or vice-versa (see
+ If MERGE_B->sources_ancestral is set, then SOURCE->url1@rev1 must be a
+ historical ancestor of SOURCE->url2@rev2, or vice-versa (see
`MERGEINFO MERGE SOURCE NORMALIZATION' for more requirements around
- the values of URL1, REVISION1, URL2, and REVISION2 in this case).
+ SOURCE in this case).
*/
static svn_error_t *
drive_merge_report_editor(const char *target_abspath,
- const char *url1,
- svn_revnum_t revision1,
- const char *url2,
- svn_revnum_t revision2,
+ const merge_source_t *source,
const apr_array_header_t *children_with_mergeinfo,
svn_depth_t depth,
notification_receiver_baton_t *notify_b,
@@ -4905,18 +4874,18 @@ drive_merge_report_editor(const char *ta
svn_revnum_t target_start;
svn_boolean_t honor_mergeinfo;
const char *old_sess2_url;
- svn_boolean_t is_rollback = revision1 > revision2;
+ svn_boolean_t is_rollback = source->rev1 > source->rev2;
honor_mergeinfo = HONOR_MERGEINFO(merge_b);
/* Start with a safe default starting revision for the editor and the
merge target. */
- target_start = revision1;
+ target_start = source->rev1;
/* If we are honoring mergeinfo the starting revision for the merge target
- might not be REVISION1, in fact the merge target might not need *any*
- part of REVISION1:REVISION2 merged -- Instead some subtree of the target
- needs REVISION1:REVISION2 -- So get the right starting revision for the
+ might not be SOURCE->rev1, in fact the merge target might not need *any*
+ part of SOURCE merged -- Instead some subtree of the target
+ needs SOURCE -- So get the right starting revision for the
target. */
if (honor_mergeinfo)
{
@@ -4937,22 +4906,22 @@ drive_merge_report_editor(const char *ta
if (child->remaining_ranges->nelts == 0)
{
/* The merge target doesn't need anything merged. */
- target_start = revision2;
+ target_start = source->rev2;
}
else
{
/* The merge target has remaining revisions to merge. These
ranges may fully or partially overlap the range described
- by REVISION1:REVISION2 or may not intersect that range at
+ by SOURCE->rev1:rev2 or may not intersect that range at
all. */
svn_merge_range_t *range =
APR_ARRAY_IDX(child->remaining_ranges, 0,
svn_merge_range_t *);
- if ((!is_rollback && range->start > revision2)
- || (is_rollback && range->start < revision2))
+ if ((!is_rollback && range->start > source->rev2)
+ || (is_rollback && range->start < source->rev2))
{
/* Merge target's first remaining range doesn't intersect. */
- target_start = revision2;
+ target_start = source->rev2;
}
else
{
@@ -4963,17 +4932,17 @@ drive_merge_report_editor(const char *ta
}
}
- /* Temporarily point our second RA session to URL1, too. We use
+ /* Temporarily point our second RA session to SOURCE->url1, too. We use
this to request individual file contents. */
SVN_ERR(svn_client__ensure_ra_session_url(&old_sess2_url,
merge_b->ra_session2,
- url1, scratch_pool));
+ source->url1, scratch_pool));
/* Get the diff editor and a reporter with which to, ultimately,
drive it. */
SVN_ERR(svn_client__get_diff_editor(&diff_editor, &diff_edit_baton,
depth,
- merge_b->ra_session2, revision1,
+ merge_b->ra_session2, source->rev1,
FALSE /* walk_deleted_dirs */,
TRUE /* text_deltas */,
&merge_callbacks, merge_b,
@@ -4982,10 +4951,11 @@ drive_merge_report_editor(const char *ta
notification_receiver, notify_b,
scratch_pool));
SVN_ERR(svn_ra_do_diff3(merge_b->ra_session1,
- &reporter, &report_baton, revision2,
+ &reporter, &report_baton, source->rev2,
"", depth, merge_b->ignore_ancestry,
TRUE, /* text_deltas */
- url2, diff_editor, diff_edit_baton, scratch_pool));
+ source->url2, diff_editor, diff_edit_baton,
+ scratch_pool));
/* Drive the reporter. */
SVN_ERR(reporter->set_path(report_baton, "", target_start, depth,
@@ -5004,11 +4974,10 @@ drive_merge_report_editor(const char *ta
{
svn_merge_range_t *range;
const char *child_repos_path;
- svn_client__merge_path_t *parent;
- svn_client__merge_path_t *child =
+ const svn_client__merge_path_t *parent;
+ const svn_client__merge_path_t *child =
APR_ARRAY_IDX(children_with_mergeinfo, i,
svn_client__merge_path_t *);
- int parent_index;
SVN_ERR_ASSERT(child);
if (child->absent)
@@ -5017,23 +4986,21 @@ drive_merge_report_editor(const char *ta
svn_pool_clear(iterpool);
/* Find this child's nearest wc ancestor with mergeinfo. */
- 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 a subtree needs the same range applied as its nearest parent
with mergeinfo or neither the subtree nor this parent need
- REVISION1:REVISION2 merged, then we don't need to describe the
+ SOURCE->rev1:rev2 merged, then we don't need to describe the
subtree separately. In the latter case this could break the
- editor if child->abspath didn't exist at REVISION2 and we
+ editor if child->abspath didn't exist at SOURCE->rev2 and we
attempt to describe it via a reporter set_path call. */
if (child->remaining_ranges->nelts)
{
range = APR_ARRAY_IDX(child->remaining_ranges, 0,
svn_merge_range_t *);
- if ((!is_rollback && range->start > revision2)
- || (is_rollback && range->start < revision2))
+ if ((!is_rollback && range->start > source->rev2)
+ || (is_rollback && range->start < source->rev2))
{
/* This child's first remaining range comes after the range
we are currently merging, so skip it. We expect to get
@@ -5071,14 +5038,14 @@ drive_merge_report_editor(const char *ta
SVN_ERR_ASSERT(child_repos_path);
if ((child->remaining_ranges->nelts == 0)
- || (is_rollback && (range->start < revision2))
- || (!is_rollback && (range->start > revision2)))
+ || (is_rollback && (range->start < source->rev2))
+ || (!is_rollback && (range->start > source->rev2)))
{
/* Nothing to merge to this child. We'll claim we have
it up to date so the server doesn't send us
anything. */
SVN_ERR(reporter->set_path(report_baton, child_repos_path,
- revision2, depth, FALSE,
+ source->rev2, depth, FALSE,
NULL, iterpool));
}
else
@@ -5103,77 +5070,49 @@ drive_merge_report_editor(const char *ta
}
/* Iterate over each svn_client__merge_path_t * element in
- CHILDREN_WITH_MERGEINFO and find the most inclusive start revision
- among those element's first remaining_ranges element.
-
- If IS_ROLLBACK is true the youngest revision is considered the "most
- inclusive" otherwise the oldest revision is.
+ CHILDREN_WITH_MERGEINFO and, if START_REV is true, find the most inclusive
+ start revision among those element's first remaining_ranges element. If
+ START_REV is false, then look for the most inclusive end revision.
+
+ If IS_ROLLBACK is true the youngest start or end (as per START_REV)
+ revision is considered the "most inclusive" otherwise the oldest revision
+ is.
If none of CHILDREN_WITH_MERGEINFO's elements have any remaining ranges
return SVN_INVALID_REVNUM. */
static svn_revnum_t
-get_most_inclusive_start_rev(const apr_array_header_t *children_with_mergeinfo,
- svn_boolean_t is_rollback)
+get_most_inclusive_rev(const apr_array_header_t *children_with_mergeinfo,
+ svn_boolean_t is_rollback,
+ svn_boolean_t start_rev)
{
int i;
- svn_revnum_t start_rev = SVN_INVALID_REVNUM;
+ svn_revnum_t most_inclusive_rev = SVN_INVALID_REVNUM;
for (i = 0; i < children_with_mergeinfo->nelts; i++)
{
svn_client__merge_path_t *child =
APR_ARRAY_IDX(children_with_mergeinfo, i, svn_client__merge_path_t *);
- svn_merge_range_t *range;
if ((! child) || child->absent)
continue;
- if (! child->remaining_ranges->nelts)
- continue;
- range = APR_ARRAY_IDX(child->remaining_ranges, 0, svn_merge_range_t *);
- if ((i == 0) && (range->start == range->end))
- continue;
- if ((start_rev == SVN_INVALID_REVNUM)
- || (is_rollback && (range->start > start_rev))
- || ((! is_rollback) && (range->start < start_rev)))
- start_rev = range->start;
- }
- return start_rev;
-}
-
-/* Iterate over each svn_client__merge_path_t * element in
- CHILDREN_WITH_MERGEINFO and find the most inclusive end revision
- among those element's first remaining_ranges element.
-
- If IS_ROLLBACK is true the oldest revision is considered the "most
- inclusive" otherwise the youngest revision is.
-
- If none of CHILDREN_WITH_MERGEINFO's elements have any remaining ranges
- return SVN_INVALID_REVNUM. */
-static svn_revnum_t
-get_most_inclusive_end_rev(const apr_array_header_t *children_with_mergeinfo,
- svn_boolean_t is_rollback)
-{
- int i;
- svn_revnum_t end_rev = SVN_INVALID_REVNUM;
-
- for (i = 0; i < children_with_mergeinfo->nelts; i++)
- {
- svn_client__merge_path_t *child =
- APR_ARRAY_IDX(children_with_mergeinfo, i, svn_client__merge_path_t *);
- if (!child || child->absent)
- continue;
if (child->remaining_ranges->nelts > 0)
{
- svn_merge_range_t *range = APR_ARRAY_IDX(child->remaining_ranges, 0,
- svn_merge_range_t *);
- if ((end_rev == SVN_INVALID_REVNUM)
- || (is_rollback && (range->end > end_rev))
- || ((! is_rollback) && (range->end < end_rev)))
- end_rev = range->end;
+ svn_merge_range_t *range =
+ APR_ARRAY_IDX(child->remaining_ranges, 0, svn_merge_range_t *);
+
+ /* Are we looking for the most inclusive start or end rev? */
+ svn_revnum_t rev = start_rev ? range->start : range->end;
+
+ if ((most_inclusive_rev == SVN_INVALID_REVNUM)
+ || (is_rollback && (rev > most_inclusive_rev))
+ || ((! is_rollback) && (rev < most_inclusive_rev)))
+ most_inclusive_rev = rev;
}
}
- return end_rev;
+ return most_inclusive_rev;
}
+
/* If first item in each child of CHILDREN_WITH_MERGEINFO's
remaining_ranges is inclusive of END_REV, Slice the first range in
to two at END_REV. All the allocations are persistent and allocated
@@ -5200,29 +5139,15 @@ slice_remaining_ranges(apr_array_header_
|| (!is_rollback && (range->start < end_rev)
&& (range->end > end_rev)))
{
- int j;
svn_merge_range_t *split_range1, *split_range2;
- apr_array_header_t *orig_remaining_ranges =
- child->remaining_ranges;
+
split_range1 = svn_merge_range_dup(range, pool);
split_range2 = svn_merge_range_dup(range, pool);
split_range1->end = end_rev;
split_range2->start = end_rev;
- child->remaining_ranges =
- apr_array_make(pool, (child->remaining_ranges->nelts + 1),
- sizeof(svn_merge_range_t *));
- APR_ARRAY_PUSH(child->remaining_ranges,
- svn_merge_range_t *) = split_range1;
- APR_ARRAY_PUSH(child->remaining_ranges,
- svn_merge_range_t *) = split_range2;
- for (j = 1; j < orig_remaining_ranges->nelts; j++)
- {
- svn_merge_range_t *orig_range =
- APR_ARRAY_IDX(orig_remaining_ranges, j,
- svn_merge_range_t *);
- APR_ARRAY_PUSH(child->remaining_ranges,
- svn_merge_range_t *) = orig_range;
- }
+ APR_ARRAY_IDX(child->remaining_ranges, 0,
+ svn_merge_range_t *) = split_range1;
+ svn_sort__array_insert(&split_range2, child->remaining_ranges, 1);
}
}
}
@@ -5238,9 +5163,11 @@ slice_remaining_ranges(apr_array_header_
new remaining_ranges array in POOL.
### TODO: We should have remaining_ranges in reverse order to avoid
- ### recreating and reallocationg the remaining_ranges every time we want
+ ### recreating and reallocating the remaining_ranges every time we want
### to remove the first range. If the ranges were reversed we could simply
- ### pop the last element in the array. */
+ ### pop the last element in the array. Alternatively we might be able to
+ ### make svn_sort__array_delete() efficient: it could increment 'elts'
+ ### (and decrement 'nelts' and 'nalloc') instead of moving elements. */
static void
remove_first_range_from_remaining_ranges(svn_revnum_t revision,
apr_array_header_t
@@ -5262,22 +5189,7 @@ remove_first_range_from_remaining_ranges
APR_ARRAY_IDX(child->remaining_ranges, 0, svn_merge_range_t *);
if (first_range->end == revision)
{
- apr_array_header_t *orig_remaining_ranges =
- child->remaining_ranges;
- int j;
-
- child->remaining_ranges =
- apr_array_make(pool, (child->remaining_ranges->nelts - 1),
- sizeof(svn_merge_range_t *));
- for (j = 1; j < orig_remaining_ranges->nelts; j++)
- {
- svn_merge_range_t *range =
- APR_ARRAY_IDX(orig_remaining_ranges,
- j,
- svn_merge_range_t *);
- APR_ARRAY_PUSH(child->remaining_ranges,
- svn_merge_range_t *) = range;
- }
+ svn_sort__array_delete(child->remaining_ranges, 0, 1);
}
}
}
@@ -5322,31 +5234,30 @@ single_file_merge_get_file(const char **
/* Send a notification specific to a single-file merge if the states
indicate there's something worth reporting.
- If *HEADER_SENT is not set and HEADER_NOTIFICATION is not NULL, then
- send the header notification before sending the state notification,
- and set *HEADER_SENT to TRUE. */
+ If *HEADER_SENT is not set, then send a header notification for range R
+ before sending the state notification, and set *HEADER_SENT to TRUE. */
static APR_INLINE void
-single_file_merge_notify(void *notify_baton,
- const char *local_abspath,
+single_file_merge_notify(notification_receiver_baton_t *notify_baton,
+ const char *target_relpath,
svn_wc_notify_action_t action,
svn_wc_notify_state_t text_state,
svn_wc_notify_state_t prop_state,
- svn_wc_notify_t *header_notification,
+ const svn_merge_range_t *r,
svn_boolean_t *header_sent,
apr_pool_t *pool)
[... 4146 lines stripped ...]