Skip to content

Commit

Permalink
On the 'apply-processor' branch: Revert revisions, where some callbac…
Browse files Browse the repository at this point in the history
…ks were

inlined into notify func; Unfortunately, this wouldn't work :(

Reverted revisions: 1922141, 1922142, 1922143, 1922144, 1922195

git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/apply-processor@1922198 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
rinrab committed Nov 28, 2024
1 parent 480b945 commit b5c7444
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 75 deletions.
14 changes: 14 additions & 0 deletions subversion/libsvn_client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,20 @@ svn_client__compatible_wc_version_optional_pristine(apr_pool_t *result_pool);

typedef struct svn_client__apply_processor_callbacks_t
{
svn_error_t *(*conflicted_path)(void *baton,
const char *path,
svn_boolean_t tree_conflict,
apr_pool_t *pool);

svn_error_t *(*skipped_path)(void *baton,
const char *path,
apr_pool_t *pool);

svn_error_t *(*updated_path)(void *baton,
const char *local_abspath,
svn_wc_notify_action_t action,
apr_pool_t *pool);

svn_error_t *(*mergeinfo_changed)(void *baton,
const char *local_abspath,
const svn_string_t *old_mergeinfo,
Expand Down
170 changes: 95 additions & 75 deletions subversion/libsvn_client/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -1283,81 +1283,6 @@ notify_merging(void *baton,
apr_pool_t *pool)
{
struct notify_begin_state_t *b = baton;
merge_cmd_baton_t *merge_b = b->merge_b;

switch (notify->action)
{
case svn_wc_notify_update_update:
if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
{
store_path(merge_b->merged_abspaths, notify->path);
}
break;

case svn_wc_notify_update_delete:
/* Update the lists of merged, skipped, tree-conflicted and added paths. */
if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
{
/* Issue #4166: If a previous merge added NOTIFY_ABSPATH, but we
are now deleting it, then remove it from the list of added
paths. */
svn_hash_sets(merge_b->added_abspaths, notify->path, NULL);
store_path(merge_b->merged_abspaths, notify->path);
}

/* Note in children_with_mergeinfo that all paths in this subtree are
* being deleted, to avoid trying to set mergeinfo on them later. */
if (merge_b->children_with_mergeinfo)
{
int i;

for (i = 0; i < merge_b->children_with_mergeinfo->nelts; i++)
{
svn_client__merge_path_t *child
= APR_ARRAY_IDX(merge_b->children_with_mergeinfo, i,
svn_client__merge_path_t *);

if (svn_dirent_is_ancestor(notify->path, child->abspath))
{
SVN_ERR(svn_sort__array_delete2(merge_b->children_with_mergeinfo, i--, 1));
}
}
}

break;

case svn_wc_notify_update_add:
if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
{
store_path(merge_b->added_abspaths, notify->path);
}
break;

case svn_wc_notify_skip:
if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
{
store_path(merge_b->skipped_abspaths, notify->path);
}
break;

case svn_wc_notify_tree_conflict:
if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
{
alloc_and_store_path(&merge_b->tree_conflicted_abspaths, notify->path,
merge_b->pool);
}

alloc_and_store_path(&merge_b->conflicted_paths, notify->path,
merge_b->pool);
break;
}

if (notify->content_state == svn_wc_notify_state_conflicted ||
notify->prop_state == svn_wc_notify_state_conflicted)
{
alloc_and_store_path(&merge_b->conflicted_paths, notify->path,
merge_b->pool);
}

notify_merge_begin(b, notify->path,
notify->action == svn_wc_notify_update_delete,
Expand Down Expand Up @@ -7316,6 +7241,98 @@ ensure_ra_session_url(svn_ra_session_t **ra_session,
return SVN_NO_ERROR;
}

/* Implements svn_client__apply_processor_callbacks_t::conflicted_path */
static svn_error_t *
apply_processor_conflicted_path(void *baton, const char *local_abspath,
svn_boolean_t tree_conflict, apr_pool_t *pool)
{
merge_cmd_baton_t *merge_b = baton;

alloc_and_store_path(&merge_b->conflicted_paths, local_abspath,
merge_b->pool);

if (tree_conflict)
alloc_and_store_path(&merge_b->tree_conflicted_abspaths,
local_abspath,
merge_b->pool);

return SVN_NO_ERROR;
}

/* Implements svn_client__apply_processor_callbacks_t::skipped_path */
static svn_error_t *
apply_processor_skipped_path(void *baton, const char *local_abspath,
apr_pool_t *pool)
{
merge_cmd_baton_t *merge_b = baton;

if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
{
store_path(merge_b->skipped_abspaths, local_abspath);
}

return SVN_NO_ERROR;
}

/* Implements svn_client__apply_processor_callbacks_t::updated_path */
static svn_error_t *
apply_processor_updated_path(void *baton, const char *local_abspath,
svn_wc_notify_action_t action, apr_pool_t *pool)
{
merge_cmd_baton_t *merge_b = baton;

switch (action)
{
case svn_wc_notify_update_update:
if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
{
store_path(merge_b->merged_abspaths, local_abspath);
}
break;

case svn_wc_notify_update_delete:
/* Update the lists of merged, skipped, tree-conflicted and added paths. */
if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
{
/* Issue #4166: If a previous merge added NOTIFY_ABSPATH, but we
are now deleting it, then remove it from the list of added
paths. */
svn_hash_sets(merge_b->added_abspaths, local_abspath, NULL);
store_path(merge_b->merged_abspaths, local_abspath);
}

/* Note in children_with_mergeinfo that all paths in this subtree are
* being deleted, to avoid trying to set mergeinfo on them later. */
if (merge_b->children_with_mergeinfo)
{
int i;

for (i = 0; i < merge_b->children_with_mergeinfo->nelts; i++)
{
svn_client__merge_path_t *child
= APR_ARRAY_IDX(merge_b->children_with_mergeinfo, i,
svn_client__merge_path_t *);

if (svn_dirent_is_ancestor(local_abspath, child->abspath))
{
SVN_ERR(svn_sort__array_delete2(merge_b->children_with_mergeinfo, i--, 1));
}
}
}

break;

case svn_wc_notify_update_add:
if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
{
store_path(merge_b->added_abspaths, local_abspath);
}
break;
}

return SVN_NO_ERROR;
}

/* Implements svn_client__apply_processor_callbacks_t::mergeinfo_changed */
static svn_error_t *
apply_processor_mergeinfo_changed(void *baton, const char *local_abspath,
Expand Down Expand Up @@ -7629,6 +7646,9 @@ do_merge(apr_hash_t **modified_subtrees,
const svn_diff_tree_processor_t *processor;
svn_client__apply_processor_callbacks_t cb_table = { 0 };

cb_table.conflicted_path = apply_processor_conflicted_path;
cb_table.skipped_path = apply_processor_skipped_path;
cb_table.updated_path = apply_processor_updated_path;
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;
Expand Down
91 changes: 91 additions & 0 deletions subversion/libsvn_client/merge_processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,13 @@ record_skip(merge_apply_processor_baton_t *merge_b,
if (merge_b->record_only)
return SVN_NO_ERROR; /* ### Why? - Legacy compatibility */

if (merge_b->cb_table && merge_b->cb_table->skipped_path
&& !(pdb && pdb->shadowed))
{
SVN_ERR(merge_b->cb_table->skipped_path(merge_b->cb_baton, local_abspath,
scratch_pool));
}

if (merge_b->notify_func)
{
svn_wc_notify_t *notify;
Expand Down Expand Up @@ -580,6 +587,12 @@ record_tree_conflict(merge_apply_processor_baton_t *merge_b,
if (merge_b->record_only)
return SVN_NO_ERROR;

if (merge_b->cb_table && merge_b->cb_table->conflicted_path)
{
SVN_ERR(merge_b->cb_table->conflicted_path(
merge_b->cb_baton, local_abspath, TRUE, scratch_pool));
}

if (!merge_b->dry_run)
{
svn_wc_conflict_description2_t *conflict;
Expand Down Expand Up @@ -689,6 +702,13 @@ record_update_add(merge_apply_processor_baton_t *merge_b,
svn_boolean_t notify_replaced,
apr_pool_t *scratch_pool)
{
if (merge_b->cb_table && merge_b->cb_table->updated_path)
{
SVN_ERR(merge_b->cb_table->updated_path(merge_b->cb_baton, local_abspath,
svn_wc_notify_update_add,
scratch_pool));
}

if (merge_b->notify_func)
{
svn_wc_notify_t *notify;
Expand Down Expand Up @@ -717,6 +737,13 @@ record_update_update(merge_apply_processor_baton_t *merge_b,
svn_wc_notify_state_t prop_state,
apr_pool_t *scratch_pool)
{
if (merge_b->cb_table && merge_b->cb_table->updated_path)
{
SVN_ERR(merge_b->cb_table->updated_path(merge_b->cb_baton, local_abspath,
svn_wc_notify_update_update,
scratch_pool));
}

if (merge_b->notify_func)
{
svn_wc_notify_t *notify;
Expand All @@ -743,6 +770,13 @@ record_update_delete(merge_apply_processor_baton_t *merge_b,
svn_node_kind_t kind,
apr_pool_t *scratch_pool)
{
if (merge_b->cb_table && merge_b->cb_table->updated_path)
{
SVN_ERR(merge_b->cb_table->updated_path(merge_b->cb_baton, local_abspath,
svn_wc_notify_update_delete,
scratch_pool));
}

if (parent_db)
{
const char *dup_abspath = apr_pstrdup(parent_db->pool, local_abspath);
Expand Down Expand Up @@ -849,6 +883,12 @@ mark_dir_edited(merge_apply_processor_baton_t *merge_b,
notify,
scratch_pool);
}

if (merge_b->cb_table && merge_b->cb_table->skipped_path)
{
SVN_ERR(merge_b->cb_table->skipped_path(
merge_b->cb_baton, local_abspath, scratch_pool));
}
}
else if (db->tree_conflict_reason != CONFLICT_REASON_NONE)
{
Expand Down Expand Up @@ -922,6 +962,12 @@ mark_file_edited(merge_apply_processor_baton_t *merge_b,
notify,
scratch_pool);
}

if (merge_b->cb_table && merge_b->cb_table->skipped_path)
{
SVN_ERR(merge_b->cb_table->skipped_path(
merge_b->cb_baton, local_abspath, scratch_pool));
}
}
else if (fb->tree_conflict_reason != CONFLICT_REASON_NONE)
{
Expand Down Expand Up @@ -1261,6 +1307,12 @@ merge_file_changed(const char *relpath,
NULL, NULL,
ctx->cancel_func, ctx->cancel_baton,
scratch_pool));
if (merge_b->cb_table && merge_b->cb_table->conflicted_path
&& property_state == svn_wc_notify_state_conflicted)
{
SVN_ERR(merge_b->cb_table->conflicted_path(
merge_b->cb_baton, local_abspath, FALSE, scratch_pool));
}
}

/* Easy out: We are only applying mergeinfo differences. */
Expand Down Expand Up @@ -1320,6 +1372,16 @@ merge_file_changed(const char *relpath,
ctx->cancel_baton,
scratch_pool));

if (content_outcome == svn_wc_merge_conflict
|| property_state == svn_wc_notify_state_conflicted)
{
if (merge_b->cb_table && merge_b->cb_table->conflicted_path)
{
SVN_ERR(merge_b->cb_table->conflicted_path(
merge_b->cb_baton, local_abspath, FALSE, scratch_pool));
}
}

if (content_outcome == svn_wc_merge_conflict)
text_state = svn_wc_notify_state_conflicted;
else if (has_local_mods
Expand Down Expand Up @@ -1399,6 +1461,14 @@ merge_file_added(const char *relpath,
return SVN_NO_ERROR;
}

if (merge_b->cb_table && merge_b->cb_table->updated_path
&& ( !fb->parent_baton || !fb->parent_baton->added))
{
SVN_ERR(merge_b->cb_table->updated_path(merge_b->cb_baton, local_abspath,
svn_wc_notify_update_add,
scratch_pool));
}

if (!merge_b->dry_run)
{
const char *copyfrom_url;
Expand Down Expand Up @@ -2187,6 +2257,13 @@ merge_dir_changed(const char *relpath,
ctx->cancel_func, ctx->cancel_baton,
scratch_pool));

if (merge_b->cb_table && merge_b->cb_table->conflicted_path &&
prop_state == svn_wc_notify_state_conflicted)
{
SVN_ERR(merge_b->cb_table->conflicted_path(
merge_b->cb_baton, local_abspath, FALSE, scratch_pool));
}

if (prop_state == svn_wc_notify_state_conflicted
|| prop_state == svn_wc_notify_state_merged
|| prop_state == svn_wc_notify_state_changed)
Expand Down Expand Up @@ -2248,6 +2325,14 @@ merge_dir_added(const char *relpath,
&& ! merge_b->record_only /* Skip details from merge_open_dir() */
);

if (merge_b->cb_table && merge_b->cb_table->updated_path
&& ( !db->parent_baton || !db->parent_baton->added))
{
SVN_ERR(merge_b->cb_table->updated_path(
merge_b->cb_baton, local_abspath, svn_wc_notify_update_add,
scratch_pool));
}

if (merge_b->same_repos)
{
/* When the directory was added in merge_dir_added() we didn't update its
Expand Down Expand Up @@ -2333,6 +2418,12 @@ merge_dir_added(const char *relpath,
merge_b->ctx->cancel_func,
merge_b->ctx->cancel_baton,
scratch_pool));
if (merge_b->cb_table && merge_b->cb_table->conflicted_path &&
prop_state == svn_wc_notify_state_conflicted)
{
SVN_ERR(merge_b->cb_table->conflicted_path(
merge_b->cb_baton, local_abspath, FALSE, scratch_pool));
}
}

return SVN_NO_ERROR;
Expand Down

0 comments on commit b5c7444

Please sign in to comment.