Skip to content

Commit

Permalink
On the 'apply-processor' branch: Add cb_table->adjust_merge_source() …
Browse files Browse the repository at this point in the history
…callback

whose implementations may adjust the source for tree conflict.

* subversion/libsvn_client/client.h
  (svn_client__apply_processor_callbacks_t): Add adjust_merge_source method.
* subversion/libsvn_client/merge.c
  (apply_processor_adjust_merge_source): Implement function.
  (do_merge): Initialize cb_table.adjust_merge_source with a pointer to the
   apply_processor_adjust_merge_source function.
* subversion/libsvn_client/merge_processor.c
  (record_tree_conflict): Move code disabled by TODO_FILTER_MERGEINFO to
   merge.c::apply_processor_adjust_merge_source(), but call it instead, do
   a little rearrangement of the local variables, invoke make_conflict_versions()
   once, but use the adjusted source.

git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/apply-processor@1922163 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
rinrab committed Nov 27, 2024
1 parent 3b95748 commit ee6ce43
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 41 deletions.
7 changes: 7 additions & 0 deletions subversion/libsvn_client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,13 @@ typedef struct svn_client__apply_processor_callbacks_t
const char *local_abspath,
apr_pool_t *scratch_pool,
apr_pool_t *result_pool);

svn_error_t *(*adjust_merge_source)(void *baton,
svn_client__merge_source_t **source_p,
const char *local_abspath,
svn_wc_conflict_action_t action,
apr_pool_t *scratch_pool,
apr_pool_t *result_pool);
} svn_client__apply_processor_callbacks_t;

/* Return a diff processor that will apply the merge to the WC.
Expand Down
45 changes: 45 additions & 0 deletions subversion/libsvn_client/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -7365,6 +7365,50 @@ apply_processor_adjust_mergeinfo(void *baton,
return SVN_NO_ERROR;
}

/* Implements svn_client__apply_processor_callbacks_t::adjust_merge_source */
static svn_error_t *
apply_processor_adjust_merge_source(void *baton,
svn_client__merge_source_t **source_p,
const char *local_abspath,
svn_wc_conflict_action_t action,
apr_pool_t *scratch_pool,
apr_pool_t *result_pool)
{
merge_cmd_baton_t *merge_b = baton;
svn_client__merge_source_t *source = *source_p;

if (HONOR_MERGEINFO(merge_b) && source->ancestral)
{
svn_client__pathrev_t *loc1;
svn_client__pathrev_t *loc2;
svn_revnum_t start_rev;
svn_revnum_t end_rev;

/* We are honoring mergeinfo so do not blindly record
* a conflict describing the merge of
* SOURCE->LOC1->URL@SOURCE->LOC1->REV through
* SOURCE->LOC2->URL@SOURCE->LOC2->REV
* but figure out the actual revision range merged. */
(void)find_nearest_ancestor_with_intersecting_ranges(
&start_rev, &end_rev,
merge_b->children_with_mergeinfo,
action != svn_wc_conflict_action_delete,
local_abspath);

loc1 = svn_client__pathrev_dup(source->loc1, scratch_pool);
loc2 = svn_client__pathrev_dup(source->loc2, scratch_pool);
loc1->rev = start_rev;
loc2->rev = end_rev;

source = svn_client__merge_source_create(loc1, loc2,
source->ancestral,
result_pool);
}

*source_p = source;
return SVN_NO_ERROR;
}

/* Drive a merge of MERGE_SOURCES into working copy node TARGET
and possibly record mergeinfo describing the merge -- see
RECORD_MERGEINFO().
Expand Down Expand Up @@ -7583,6 +7627,7 @@ do_merge(apr_hash_t **modified_subtrees,

cb_table.mergeinfo_changed = apply_processor_mergeinfo_changed;
cb_table.adjust_mergeinfo = apply_processor_adjust_mergeinfo;
cb_table.adjust_merge_source = apply_processor_adjust_merge_source;

svn_pool_clear(iterpool);

Expand Down
55 changes: 14 additions & 41 deletions subversion/libsvn_client/merge_processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ record_tree_conflict(merge_apply_processor_baton_t *merge_b,
const svn_wc_conflict_version_t *right;
apr_pool_t *result_pool = parent_baton ? parent_baton->pool
: scratch_pool;
svn_client__merge_source_t *source;

if (reason == svn_wc_conflict_reason_deleted)
{
Expand All @@ -613,49 +614,21 @@ record_tree_conflict(merge_apply_processor_baton_t *merge_b,
reason = svn_wc_conflict_reason_moved_here;
}

#if TODO_FILTER_MERGEINFO
if (HONOR_MERGEINFO(merge_b) && merge_b->merge_source.ancestral)
source = &merge_b->merge_source;

if (merge_b->cb_table && merge_b->cb_table->adjust_merge_source)
{
svn_client__merge_source_t *source;
svn_client__pathrev_t *loc1;
svn_client__pathrev_t *loc2;
svn_revnum_t start_rev;
svn_revnum_t end_rev;

/* We are honoring mergeinfo so do not blindly record
* a conflict describing the merge of
* SOURCE->LOC1->URL@SOURCE->LOC1->REV through
* SOURCE->LOC2->URL@SOURCE->LOC2->REV
* but figure out the actual revision range merged. */
(void)find_nearest_ancestor_with_intersecting_ranges(
&start_rev, &end_rev,
merge_b->children_with_mergeinfo,
action != svn_wc_conflict_action_delete,
local_abspath);

loc1 = svn_client__pathrev_dup(merge_b->merge_source.loc1,
scratch_pool);
loc2 = svn_client__pathrev_dup(merge_b->merge_source.loc2,
scratch_pool);
loc1->rev = start_rev;
loc2->rev = end_rev;
source = svn_client__merge_source_create(loc1, loc2,
merge_b->merge_source.ancestral,
scratch_pool);
SVN_ERR(merge_b->cb_table->adjust_merge_source(
merge_b->cb_baton, &source,
local_abspath, action,
scratch_pool, scratch_pool));
}

SVN_ERR(make_conflict_versions(&left, &right, local_abspath,
merge_left_node_kind,
merge_right_node_kind,
source, merge_b->target,
result_pool, scratch_pool));
}
else
#endif
SVN_ERR(make_conflict_versions(&left, &right, local_abspath,
merge_left_node_kind,
merge_right_node_kind,
&merge_b->merge_source, merge_b->target,
result_pool, scratch_pool));
SVN_ERR(make_conflict_versions(&left, &right, local_abspath,
merge_left_node_kind,
merge_right_node_kind,
source, merge_b->target,
result_pool, scratch_pool));

/* Fix up delete of file, add of dir replacement (or other way around) */
if (existing_conflict != NULL && existing_conflict->src_left_version)
Expand Down

0 comments on commit ee6ce43

Please sign in to comment.