Author: svn-role
Date: Sat Dec 19 04:00:12 2020
New Revision: 1884617

URL: http://svn.apache.org/viewvc?rev=1884617&view=rev
Log:
Merge r1880192 from trunk:

 * r1880192
   Fix issue #4862 "Merge: the resulting mergeinfo is non-deterministic".
   Justification:
     Non-deterministic merge result is bad.
   Depends:
     r1878997, r1879192, r1879474, r1879959 (Fix issue #4859)
   Votes:
     +1: julianfoad, hartmannathan, jcorvel

Modified:
    subversion/branches/1.14.x/   (props changed)
    subversion/branches/1.14.x/STATUS
    subversion/branches/1.14.x/subversion/libsvn_client/merge.c
    subversion/branches/1.14.x/subversion/tests/cmdline/merge_tests.py

Propchange: subversion/branches/1.14.x/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1880192

Modified: subversion/branches/1.14.x/STATUS
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.14.x/STATUS?rev=1884617&r1=1884616&r2=1884617&view=diff
==============================================================================
--- subversion/branches/1.14.x/STATUS (original)
+++ subversion/branches/1.14.x/STATUS Sat Dec 19 04:00:12 2020
@@ -53,15 +53,6 @@ Veto-blocked changes:
 Approved changes:
 =================
 
- * r1880192
-   Fix issue #4862 "Merge: the resulting mergeinfo is non-deterministic".
-   Justification:
-     Non-deterministic merge result is bad.
-   Depends:
-     r1878997, r1879192, r1879474, r1879959 (Fix issue #4859)
-   Votes:
-     +1: julianfoad, hartmannathan, jcorvel
-
  * r1881985, r1882105
    Follow up to r1880192: Fix an EOL issue in test on Windows.
    Justification:

Modified: subversion/branches/1.14.x/subversion/libsvn_client/merge.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/libsvn_client/merge.c?rev=1884617&r1=1884616&r2=1884617&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/libsvn_client/merge.c (original)
+++ subversion/branches/1.14.x/subversion/libsvn_client/merge.c Sat Dec 19 
04:00:12 2020
@@ -7915,18 +7915,23 @@ process_children_with_new_mergeinfo(merg
                                     apr_pool_t *pool)
 {
   apr_pool_t *iterpool;
-  apr_hash_index_t *hi;
+  apr_array_header_t *a;
+  int i;
 
   if (!merge_b->paths_with_new_mergeinfo || merge_b->dry_run)
     return SVN_NO_ERROR;
 
   /* Iterate over each path with explicit mergeinfo added by the merge. */
+  /* Iterate over the paths in a parent-to-child order so that inherited
+   * mergeinfo is propagated consistently from each parent path to its
+   * children. (Issue #4862) */
+  a = svn_sort__hash(merge_b->paths_with_new_mergeinfo,
+                     svn_sort_compare_items_as_paths, pool);
   iterpool = svn_pool_create(pool);
-  for (hi = apr_hash_first(pool, merge_b->paths_with_new_mergeinfo);
-       hi;
-       hi = apr_hash_next(hi))
+  for (i = 0; i < a->nelts; i++)
     {
-      const char *abspath_with_new_mergeinfo = apr_hash_this_key(hi);
+      svn_sort__item_t *item = &APR_ARRAY_IDX(a, i, svn_sort__item_t);
+      const char *abspath_with_new_mergeinfo = item->key;
       svn_mergeinfo_t path_inherited_mergeinfo;
       svn_mergeinfo_t path_explicit_mergeinfo;
       svn_client__merge_path_t *new_child;

Modified: subversion/branches/1.14.x/subversion/tests/cmdline/merge_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/tests/cmdline/merge_tests.py?rev=1884617&r1=1884616&r2=1884617&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/tests/cmdline/merge_tests.py 
(original)
+++ subversion/branches/1.14.x/subversion/tests/cmdline/merge_tests.py Sat Dec 
19 04:00:12 2020
@@ -18609,12 +18609,12 @@ def merge_deleted_folder_with_mergeinfo_
     'A/D/G2' : Item(status='A '),
     })
   # verify that mergeinfo is set/changed on A/D, A/D/G, A/D/G2.
-  #expected_mergeinfo_output = wc.State(sbox.ospath(''), {
-  #  'A'      : Item(status=' U'),
-  #  'A/D'    : Item(status=' G'),
-  #  'A/D/G'  : Item(status=' G'),  # varies, G or U: see issue #4862
-  #  'A/D/G2' : Item(status=' G'),  # varies, G or U: see issue #4862
-  #  })
+  expected_mergeinfo_output = wc.State(sbox.ospath(''), {
+    'A'      : Item(status=' U'),
+    'A/D'    : Item(status=' G'),
+    'A/D/G'  : Item(status=' G'),
+    'A/D/G2' : Item(status=' G'),
+    })
   expected_status = svntest.actions.get_virginal_state(sbox.ospath('A'), 
7).subtree('A')
   expected_status.tweak_some(
     lambda path, item: [True] if path.split('/')[0] == 'D' else [],
@@ -18628,7 +18628,7 @@ def merge_deleted_folder_with_mergeinfo_
   svntest.actions.run_and_verify_merge(sbox.ospath('A'), None, None,
                                        '^/branch_A', None,
                                        expected_output,
-                                       None, #expected_mergeinfo_output
+                                       expected_mergeinfo_output,
                                        None,
                                        None,
                                        expected_status,
@@ -18638,6 +18638,17 @@ def merge_deleted_folder_with_mergeinfo_
                                        dry_run=False  # as dry run is broken
                                        )
 
+  # verify that mergeinfo is set/changed on A/D, A/D/G, A/D/G2.
+  expected_mergeinfo = [
+    ('A',       ['/branch_A:3-7']),
+    ('A/D',     ['/branch_A/D:5-7\n', '/branch_B/C:1*']),
+    ('A/D/G',   ['/branch_A/D/G:5-7\n', '/branch_B/C/G:1*']),
+    ('A/D/G2',  ['/branch_A/D/G2:5-7\n', '/branch_B/C/G2:1*']),
+    ]
+  for path, mergeinfo in expected_mergeinfo:
+    svntest.actions.check_prop('svn:mergeinfo', sbox.ospath(path),
+                               [m.encode() for m in mergeinfo])
+
   os.chdir(was_cwd)
 
 ########################################################################


Reply via email to