Author: rinrab
Date: Mon Nov 25 18:40:20 2024
New Revision: 1922090

URL: http://svn.apache.org/viewvc?rev=1922090&view=rev
Log:
On the 'apply-processor' branch: Add callbacks for notifying merge.c's
stuff from the apply processor.

This implements most of TODO_STORE_PATH todos.

Currently, merge needs to do some records during the operation, including
changed paths, as an example. It will use them in steps such recording merged
path to the mergeinfo or conflict resolution. However, since the apply
processor cannot access the resources of merge.c, we have to tell it about
what's going on.

This commit will introduce a callback vtable for notifications like those
explained above. Then apply processor will call them as the actions done.
Then merge.c will do the work they need.

In my mind this should be a transitional code, which I will replace with
something different. I hope to use notify_func for things like those.
Generally, it seems to be possible.

* subversion/libsvn_client/client.h
  (svn_client__apply_processor_callbacks_t): Declare vtable.
    (conflicted_path,
     skipped_path,
     updated_path): New methods.
  (svn_client__apply_processor_create): Add cb_table and cb_baton arguments.
* subversion/libsvn_client/merge.c
  (apply_processor_conflicted_path,
   apply_processor_skipped_path
   apply_processor_updated_path): New functions, implementing
     svn_client__apply_processor_callbacks_t interface; Most of the
     code has been copied from merge_processor.c.
  (do_merge): Create cb_table and pass it to the apply-processor.
* subversion/libsvn_client/merge_processor.c
  (merge_apply_processor_baton_t): Add cb_table and cb_baton fields.
  (...): Invoke svn_client__apply_processor_callbacks_t's where store_path or
   other actions have been done; Enable that code by removing `if TODO_...`.

Modified:
    subversion/branches/apply-processor/subversion/libsvn_client/client.h
    subversion/branches/apply-processor/subversion/libsvn_client/merge.c
    
subversion/branches/apply-processor/subversion/libsvn_client/merge_processor.c

Modified: subversion/branches/apply-processor/subversion/libsvn_client/client.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/apply-processor/subversion/libsvn_client/client.h?rev=1922090&r1=1922089&r2=1922090&view=diff
==============================================================================
--- subversion/branches/apply-processor/subversion/libsvn_client/client.h 
(original)
+++ subversion/branches/apply-processor/subversion/libsvn_client/client.h Mon 
Nov 25 18:40:20 2024
@@ -1280,6 +1280,23 @@ svn_client__textbase_sync(svn_ra_session
 const svn_version_t *
 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_client__apply_processor_callbacks_t;
+
 /* Return a diff processor that will apply the merge to the WC.
  */
 svn_diff_tree_processor_t *
@@ -1294,6 +1311,8 @@ svn_client__apply_processor_create(const
                                    const char *diff3_cmd,
                                    const apr_array_header_t *merge_options,
                                    const apr_array_header_t *ext_patterns,
+                                   const 
svn_client__apply_processor_callbacks_t *cb_table,
+                                   void *cb_baton,
                                    svn_client_ctx_t *ctx,
                                    apr_pool_t *scratch_pool,
                                    apr_pool_t *result_pool);

Modified: subversion/branches/apply-processor/subversion/libsvn_client/merge.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/apply-processor/subversion/libsvn_client/merge.c?rev=1922090&r1=1922089&r2=1922090&view=diff
==============================================================================
--- subversion/branches/apply-processor/subversion/libsvn_client/merge.c 
(original)
+++ subversion/branches/apply-processor/subversion/libsvn_client/merge.c Mon 
Nov 25 18:40:20 2024
@@ -7240,6 +7240,98 @@ ensure_ra_session_url(svn_ra_session_t *
   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;
+}
+
 /* Drive a merge of MERGE_SOURCES into working copy node TARGET
    and possibly record mergeinfo describing the merge -- see
    RECORD_MERGEINFO().
@@ -7456,6 +7548,11 @@ do_merge(apr_hash_t **modified_subtrees,
       svn_client__merge_source_t *source =
         APR_ARRAY_IDX(merge_sources, i, svn_client__merge_source_t *);
       single_range_conflict_report_t *conflicted_range_report;
+      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;
 
       svn_pool_clear(iterpool);
 
@@ -7481,6 +7578,8 @@ do_merge(apr_hash_t **modified_subtrees,
                                                      diff3_cmd,
                                                      merge_options,
                                                      ext_patterns,
+                                                     &cb_table,
+                                                     &merge_cmd_baton,
                                                      ctx,
                                                      scratch_pool, 
scratch_pool);
 

Modified: 
subversion/branches/apply-processor/subversion/libsvn_client/merge_processor.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/apply-processor/subversion/libsvn_client/merge_processor.c?rev=1922090&r1=1922089&r2=1922090&view=diff
==============================================================================
--- 
subversion/branches/apply-processor/subversion/libsvn_client/merge_processor.c 
(original)
+++ 
subversion/branches/apply-processor/subversion/libsvn_client/merge_processor.c 
Mon Nov 25 18:40:20 2024
@@ -102,6 +102,8 @@ typedef struct merge_apply_processor_bat
   svn_wc_notify_func2_t notify_func;
   void *notify_baton;
 
+  const svn_client__apply_processor_callbacks_t *cb_table;
+  void *cb_baton;
 } merge_apply_processor_baton_t;
 
 
@@ -522,13 +524,12 @@ record_skip(merge_apply_processor_baton_
   if (merge_b->record_only)
     return SVN_NO_ERROR; /* ### Why? - Legacy compatibility */
 
-#if TODO_STORE_PATH
-  if ((merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
+  if (merge_b->cb_table && merge_b->cb_table->skipped_path
       && !(pdb && pdb->shadowed))
     {
-      store_path(merge_b->skipped_abspaths, local_abspath);
+      SVN_ERR(merge_b->cb_table->skipped_path(merge_b->cb_baton, local_abspath,
+                                              scratch_pool));
     }
-#endif
 
   if (merge_b->notify_func)
     {
@@ -573,17 +574,12 @@ record_tree_conflict(merge_apply_process
   if (merge_b->record_only)
     return SVN_NO_ERROR;
 
-#if TODO_STORE_PATH
-  if (merge_b->merge_source.ancestral
-      || merge_b->reintegrate_merge)
+  if (merge_b->cb_table && merge_b->cb_table->conflicted_path)
     {
-      store_path(merge_b->tree_conflicted_abspaths, local_abspath);
+      SVN_ERR(merge_b->cb_table->conflicted_path(
+          merge_b->cb_baton, local_abspath, TRUE, scratch_pool));
     }
 
-  alloc_and_store_path(&merge_b->conflicted_paths, local_abspath,
-                       merge_b->pool);
-#endif
-
   if (!merge_b->dry_run)
     {
        svn_wc_conflict_description2_t *conflict;
@@ -718,12 +714,12 @@ record_update_add(merge_apply_processor_
                   svn_boolean_t notify_replaced,
                   apr_pool_t *scratch_pool)
 {
-#if TODO_STORE_PATH
-  if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
+  if (merge_b->cb_table && merge_b->cb_table->updated_path)
     {
-      store_path(merge_b->merged_abspaths, local_abspath);
+      SVN_ERR(merge_b->cb_table->updated_path(merge_b->cb_baton, local_abspath,
+                                              svn_wc_notify_update_add,
+                                              scratch_pool));
     }
-#endif
 
   if (merge_b->notify_func)
     {
@@ -753,12 +749,12 @@ record_update_update(merge_apply_process
                      svn_wc_notify_state_t prop_state,
                      apr_pool_t *scratch_pool)
 {
-#if TODO_STORE_PATH
-  if (merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
+  if (merge_b->cb_table && merge_b->cb_table->updated_path)
     {
-      store_path(merge_b->merged_abspaths, local_abspath);
+      SVN_ERR(merge_b->cb_table->updated_path(merge_b->cb_baton, local_abspath,
+                                              svn_wc_notify_update_update,
+                                              scratch_pool));
     }
-#endif
 
   if (merge_b->notify_func)
     {
@@ -786,16 +782,11 @@ record_update_delete(merge_apply_process
                      svn_node_kind_t kind,
                      apr_pool_t *scratch_pool)
 {
-#if TODO_STORE_PATH
-  /* 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);
+  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)
@@ -809,26 +800,6 @@ record_update_delete(merge_apply_process
                     svn_node_kind_to_word(kind));
     }
 
-  /* 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));
-            }
-        }
-    }
-#endif
-
   return SVN_NO_ERROR;
 }
 
@@ -925,13 +896,11 @@ mark_dir_edited(merge_apply_processor_ba
                                scratch_pool);
         }
 
-#if TODO_STORE_PATH
-      if (merge_b->merge_source.ancestral
-          || merge_b->reintegrate_merge)
+      if (merge_b->cb_table && merge_b->cb_table->skipped_path)
         {
-          store_path(merge_b->skipped_abspaths, local_abspath);
+          SVN_ERR(merge_b->cb_table->skipped_path(
+              merge_b->cb_baton, local_abspath, scratch_pool));
         }
-#endif
     }
   else if (db->tree_conflict_reason != CONFLICT_REASON_NONE)
     {
@@ -1006,13 +975,11 @@ mark_file_edited(merge_apply_processor_b
                                scratch_pool);
         }
 
-#if TODO_STORE_PATH
-      if (merge_b->merge_source.ancestral
-          || merge_b->reintegrate_merge)
+      if (merge_b->cb_table && merge_b->cb_table->skipped_path)
         {
-          store_path(merge_b->skipped_abspaths, local_abspath);
+          SVN_ERR(merge_b->cb_table->skipped_path(
+              merge_b->cb_baton, local_abspath, scratch_pool));
         }
-#endif
     }
   else if (fb->tree_conflict_reason != CONFLICT_REASON_NONE)
     {
@@ -1357,13 +1324,12 @@ merge_file_changed(const char *relpath,
                                   NULL, NULL,
                                   ctx->cancel_func, ctx->cancel_baton,
                                   scratch_pool));
-#if TODO_STORE_PATH
-      if (property_state == svn_wc_notify_state_conflicted)
+      if (merge_b->cb_table && merge_b->cb_table->conflicted_path
+          && property_state == svn_wc_notify_state_conflicted)
         {
-          alloc_and_store_path(&merge_b->conflicted_paths, local_abspath,
-                               merge_b->pool);
+          SVN_ERR(merge_b->cb_table->conflicted_path(
+              merge_b->cb_baton, local_abspath, FALSE, scratch_pool));
         }
-#endif
     }
 
   /* Easy out: We are only applying mergeinfo differences. */
@@ -1423,14 +1389,15 @@ merge_file_changed(const char *relpath,
                             ctx->cancel_baton,
                             scratch_pool));
 
-#if TODO_STORE_PATH
       if (content_outcome == svn_wc_merge_conflict
           || property_state == svn_wc_notify_state_conflicted)
         {
-          alloc_and_store_path(&merge_b->conflicted_paths, local_abspath,
-                               merge_b->pool);
+          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));
+            }
         }
-#endif
 
       if (content_outcome == svn_wc_merge_conflict)
         text_state = svn_wc_notify_state_conflicted;
@@ -1511,14 +1478,13 @@ merge_file_added(const char *relpath,
       return SVN_NO_ERROR;
     }
 
-#if TODO_STORE_PATH
-  if ((merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
+  if (merge_b->cb_table && merge_b->cb_table->updated_path
       && ( !fb->parent_baton || !fb->parent_baton->added))
     {
-      /* Store the roots of added subtrees */
-      store_path(merge_b->added_abspaths, local_abspath);
+      SVN_ERR(merge_b->cb_table->updated_path(merge_b->cb_baton, local_abspath,
+                                              svn_wc_notify_update_add,
+                                              scratch_pool));
     }
-#endif
 
   if (!merge_b->dry_run)
     {
@@ -1768,11 +1734,9 @@ merge_file_deleted(const char *relpath,
     {
       if (same)
         {
-#if TODO_STORE_PATH
           /* Note that we checked this file */
           store_path(fb->parent_baton->delete_state->compared_abspaths,
                      local_abspath);
-#endif
         }
       else
         {
@@ -2294,13 +2258,12 @@ merge_dir_changed(const char *relpath,
                                   ctx->cancel_func, ctx->cancel_baton,
                                   scratch_pool));
 
-#if TODO_STORE_PATH
-      if (prop_state == svn_wc_notify_state_conflicted)
+      if (merge_b->cb_table && merge_b->cb_table->conflicted_path &&
+          prop_state == svn_wc_notify_state_conflicted)
         {
-          alloc_and_store_path(&merge_b->conflicted_paths, local_abspath,
-                               merge_b->pool);
+          SVN_ERR(merge_b->cb_table->conflicted_path(
+              merge_b->cb_baton, local_abspath, FALSE, scratch_pool));
         }
-#endif
 
       if (prop_state == svn_wc_notify_state_conflicted
           || prop_state == svn_wc_notify_state_merged
@@ -2363,14 +2326,13 @@ merge_dir_added(const char *relpath,
                  && ! merge_b->record_only /* Skip details from 
merge_open_dir() */
                  );
 
-#if TODO_STORE_PATH
-  if ((merge_b->merge_source.ancestral || merge_b->reintegrate_merge)
+  if (merge_b->cb_table && merge_b->cb_table->updated_path
       && ( !db->parent_baton || !db->parent_baton->added))
     {
-      /* Store the roots of added subtrees */
-      store_path(merge_b->added_abspaths, local_abspath);
+          SVN_ERR(merge_b->cb_table->updated_path(
+              merge_b->cb_baton, local_abspath, svn_wc_notify_update_add,
+              scratch_pool));
     }
-#endif
 
   if (merge_b->same_repos)
     {
@@ -2453,13 +2415,12 @@ merge_dir_added(const char *relpath,
                                   merge_b->ctx->cancel_func,
                                   merge_b->ctx->cancel_baton,
                                   scratch_pool));
-#if TODO_STORE_PATH
-      if (prop_state == svn_wc_notify_state_conflicted)
+      if (merge_b->cb_table && merge_b->cb_table->conflicted_path &&
+          prop_state == svn_wc_notify_state_conflicted)
         {
-          alloc_and_store_path(&merge_b->conflicted_paths, local_abspath,
-                               merge_b->pool);
+          SVN_ERR(merge_b->cb_table->conflicted_path(
+              merge_b->cb_baton, local_abspath, FALSE, scratch_pool));
         }
-#endif
     }
 
   return SVN_NO_ERROR;
@@ -2734,6 +2695,8 @@ svn_client__apply_processor_create(const
                                    const char *diff3_cmd,
                                    const apr_array_header_t *merge_options,
                                    const apr_array_header_t *ext_patterns,
+                                   const 
svn_client__apply_processor_callbacks_t *cb_table,
+                                   void *cb_baton,
                                    svn_client_ctx_t *ctx,
                                    apr_pool_t *scratch_pool,
                                    apr_pool_t *result_pool)
@@ -2754,6 +2717,8 @@ svn_client__apply_processor_create(const
   baton->dry_run = dry_run;
   baton->notify_func = notify_func;
   baton->notify_baton = notify_baton;
+  baton->cb_table = cb_table;
+  baton->cb_baton = cb_baton;
   baton->ctx = ctx;
 
   merge_processor = svn_diff__tree_processor_create(baton,


Reply via email to