changeset 5572:d7d954b6d518

evolve: remove swapping nodes logic while resolving divergence Before this patch, while solving content-divergence if one of the divergent cset need to relocate to resolution parent we used to set that cset to "other" side; so it was like we are always going to relocate "other" side which made us to swap the two if "divergent" cset need to relocate. Above mentioned solution for relocating cset was not good and led us to incorrect output in some cases. So this patch, simplify the logic and remove the swapping thing and clearly depend on resolution parent to check if any of the divergent cset needs to relocate. This also means that now in some cases if both the divergent csets needs to relocate, both will be relocated. Even before this patch, there are some cases where both the divergent csets relocated but not in every case where it should have. Coming to the changes in test files: 1) changes in order of merging the two divergent csets is due to fact that now "divergent" and "other" are not swapped and hence "divergent" will be at local side and "other" will be at "other", which also results in change in the hash id for some cases. 2) extra changesets: which is the result of the fact that now we don't miss any case where both the divergent csets should be based on resolution parent before performing the merge -> which caught some cases and performed relocation, hence extra changesets. Although you can find that there is no changes in file content because of these relocation, but I remember loosing some data because of not relocating the "divergent", so why leave any risk out there by not relocating "other" to the resolution parent.
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Sun, 20 Sep 2020 09:22:04 +0530
parents b2de5825e5ca
children 80e55fbda4a4
files hgext3rd/evolve/evolvecmd.py tests/test-evolve-content-divergent-case-A3.t tests/test-evolve-content-divergent-case-A4.t tests/test-evolve-content-divergent-interrupted.t tests/test-evolve-content-divergent-relocation.t tests/test-evolve-content-divergent-stack.t tests/test-evolve-issue5958.t
diffstat 7 files changed, 309 insertions(+), 249 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py	Fri Sep 25 11:06:46 2020 -0700
+++ b/hgext3rd/evolve/evolvecmd.py	Sun Sep 20 09:22:04 2020 +0530
@@ -301,12 +301,6 @@
         ui.write_err(hint)
         return (False, b".")
 
-    def swapnodes(div, other):
-        div, other = other, div
-        evolvestate[b'divergent'] = div.node()
-        evolvestate[b'other-divergent'] = other.node()
-        return div, other
-
     if not (divergent.mutable() and other.mutable()):
         # for simplicity, we keep public one to local side while merging
         sameparent = divergent.p1().rev() == other.p1().rev()
@@ -399,7 +393,6 @@
             pass
         if otheronly:
             relocatereq = True
-            divergent, other = swapnodes(divergent, other)
             resolutionparent = repo[succsotherp1].node()
         elif divonly:
             relocatereq = True
@@ -408,11 +401,8 @@
             pass
     elif succsotherp1 in gca and succsdivp1 not in gca:
         relocatereq = True
-        pass
     elif succsdivp1 in gca and succsotherp1 not in gca:
         relocatereq = True
-
-        divergent, other = swapnodes(divergent, other)
         resolutionparent = repo[succsotherp1].node()
     else:
         msg = _(b"skipping %s: have a different parent than %s "
@@ -499,6 +489,11 @@
         return (False, b".")
     divergent, other, resolutionparent, relocatereq = datatoproceed[1:]
 
+    if divergent.p1().node() != resolutionparent:
+        evolvestate[b'relocate-div'] = True
+    if other.p1().node() != resolutionparent:
+        evolvestate[b'relocate-other'] = True
+
     if relocatereq:
         evolvestate[b'relocation-req'] = True
     evolvestate[b'resolutionparent'] = resolutionparent
@@ -522,8 +517,8 @@
         ui.write((b'hg commit -m "`hg log -r %s --template={desc}`";\n'
                   % divergent))
         return (False, b".")
-    # relocate divergent cset to its obsolete parent's successsor
-    if divergent.p1().node() != resolutionparent or evolvestate[b'relocate-div']:
+    # relocate divergent cset to resolution parent
+    if evolvestate[b'relocate-div']:
         evolvestate[b'relocating-div'] = True
         ui.status(_(b'rebasing "divergent" content-divergent changeset %s on'
                     b' %s\n' % (divergent, repo[resolutionparent])))
@@ -537,7 +532,7 @@
         divergent = repo[newdivergent]
 
     # relocate the other divergent if required
-    if relocatereq or evolvestate[b'relocate-other']:
+    if evolvestate[b'relocate-other']:
         # relocating will help us understand during the time of conflicts that
         # whether conflicts occur at reloacting or they occured at merging
         # content divergent changesets
@@ -1976,8 +1971,8 @@
             evolvestate[b'divergent'] = newdiv
             divergent = repo[newdiv]
 
-            relocatereq = evolvestate[b'relocation-req']
-            if relocatereq:
+            if evolvestate[b'relocate-other']:
+                divergent = repo[evolvestate[b'divergent']]
                 evolvestate[b'relocating-other'] = True
                 ui.status(_(b'rebasing "other" content-divergent changeset %s on'
                             b' %s\n' % (other, resolutionparent)))
--- a/tests/test-evolve-content-divergent-case-A3.t	Fri Sep 25 11:06:46 2020 -0700
+++ b/tests/test-evolve-content-divergent-case-A3.t	Sun Sep 20 09:22:04 2020 +0530
@@ -173,15 +173,15 @@
   o  0:a9bdc8b26820 (public): O
   
   $ hg evolve --content-divergent
-  merge:[5] C
-  with: [4] C
+  merge:[4] C
+  with: [5] C
   base: [3] C
-  rebasing "other" content-divergent changeset 710d96992b40 on f6fbb35d8ac9
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 3ad062d48137
+  rebasing "divergent" content-divergent changeset 710d96992b40 on f6fbb35d8ac9
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory is now at 8f91b97f6f9a
 
   $ hg log -G
-  @  7:3ad062d48137 (draft): C
+  @  7:8f91b97f6f9a (draft): C
   |
   o  2:f6fbb35d8ac9 (draft): B
   |
@@ -192,8 +192,8 @@
   $ hg evolve -l
 
   $ hg log -pl1
-  7:3ad062d48137 (draft): C 
-  diff -r f6fbb35d8ac9 -r 3ad062d48137 C
+  7:8f91b97f6f9a (draft): C 
+  diff -r f6fbb35d8ac9 -r 8f91b97f6f9a C
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/C	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
--- a/tests/test-evolve-content-divergent-case-A4.t	Fri Sep 25 11:06:46 2020 -0700
+++ b/tests/test-evolve-content-divergent-case-A4.t	Sun Sep 20 09:22:04 2020 +0530
@@ -177,15 +177,15 @@
   o  0:a9bdc8b26820 (public): O
   
   $ hg evolve --content-divergent
-  merge:[6] D
-  with: [5] D
+  merge:[5] D
+  with: [6] D
   base: [4] D
-  rebasing "other" content-divergent changeset 5d3fd66cb347 on d90aa47aa5d3
+  rebasing "divergent" content-divergent changeset 5d3fd66cb347 on d90aa47aa5d3
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 898f6bbfb21e
+  working directory is now at b2ef9cafa8ac
 
   $ hg log -G
-  @  8:898f6bbfb21e (draft): D
+  @  8:b2ef9cafa8ac (draft): D
   |
   o  3:d90aa47aa5d3 (draft): C
   |
--- a/tests/test-evolve-content-divergent-interrupted.t	Fri Sep 25 11:06:46 2020 -0700
+++ b/tests/test-evolve-content-divergent-interrupted.t	Sun Sep 20 09:22:04 2020 +0530
@@ -198,6 +198,7 @@
   with: [7] added d
   base: [4] added d
   rebasing "divergent" content-divergent changeset e49523854bc8 on 4566502c0483
+  rebasing "other" content-divergent changeset f0f1694f123e on 4566502c0483
   merging d
   warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
@@ -206,7 +207,7 @@
   [1]
 
   $ hg evolve --abort
-  1 new orphan changesets
+  2 new orphan changesets
   2 new content-divergent changesets
   evolve aborted
   working directory is now at 491e10505bae
@@ -303,10 +304,10 @@
       () draft
 
   $ hg evolve --content-divergent
-  merge:[7] added d
-  with: [6] added d
+  merge:[6] added d
+  with: [7] added d
   base: [4] added d
-  rebasing "other" content-divergent changeset 69bdd23a9b0d on ca1b80f7960a
+  rebasing "divergent" content-divergent changeset 69bdd23a9b0d on ca1b80f7960a
   merging c
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   unresolved merge conflicts
--- a/tests/test-evolve-content-divergent-relocation.t	Fri Sep 25 11:06:46 2020 -0700
+++ b/tests/test-evolve-content-divergent-relocation.t	Sun Sep 20 09:22:04 2020 +0530
@@ -184,12 +184,12 @@
       () [default] draft
 
   $ hg evolve --content-divergent
-  merge:[13] added x
-  with: [12] added foo to x
+  merge:[12] added foo to x
+  with: [13] added x
   base: [11] added x
-  rebasing "other" content-divergent changeset 5cf74a13db18 on be5a8b9faa8a
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 4e844ab5e814
+  rebasing "divergent" content-divergent changeset 5cf74a13db18 on be5a8b9faa8a
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory is now at 618f8bd245a8
 
   $ hg exp
   # HG changeset patch
@@ -197,11 +197,11 @@
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
   # Branch bar
-  # Node ID 4e844ab5e8142d26fb1f0990486379f2410b0358
+  # Node ID 618f8bd245a8d1892954eb49a88a6ec5e500a5b5
   # Parent  be5a8b9faa8af54f115aa168a2c8564acb40c37d
   added foo to x
   
-  diff -r be5a8b9faa8a -r 4e844ab5e814 x
+  diff -r be5a8b9faa8a -r 618f8bd245a8 x
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/x	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
@@ -210,7 +210,7 @@
 The above `hg exp` and the following log call demonstrates that message, content
 and branch change is preserved in case of relocation
   $ hg glog
-  @  15:4e844ab5e814 added foo to x
+  @  15:618f8bd245a8 added foo to x
   |   () [bar] draft
   o  10:be5a8b9faa8a added d
   |   () [default] draft
@@ -234,10 +234,10 @@
   801b5920c7ea8d4ebdbc9cfc1e79e665dea2f211 5cf74a13db180e33dc2df8cd2aa70b21252a2a64 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '73', 'operation': 'amend', 'user': 'test'}
   801b5920c7ea8d4ebdbc9cfc1e79e665dea2f211 45e15d6e88f5bd23ba360dff0c7591eca2d99f43 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'}
   5cf74a13db180e33dc2df8cd2aa70b21252a2a64 911c21adca136894a2b35f0a58fae7ee94fa5e61 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'evolve', 'user': 'test'}
-  45e15d6e88f5bd23ba360dff0c7591eca2d99f43 4e844ab5e8142d26fb1f0990486379f2410b0358 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '73', 'operation': 'evolve', 'user': 'test'}
-  911c21adca136894a2b35f0a58fae7ee94fa5e61 4e844ab5e8142d26fb1f0990486379f2410b0358 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'evolve', 'user': 'test'}
+  911c21adca136894a2b35f0a58fae7ee94fa5e61 618f8bd245a8d1892954eb49a88a6ec5e500a5b5 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'evolve', 'user': 'test'}
+  45e15d6e88f5bd23ba360dff0c7591eca2d99f43 618f8bd245a8d1892954eb49a88a6ec5e500a5b5 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '73', 'operation': 'evolve', 'user': 'test'}
   $ hg obslog --all
-  @    4e844ab5e814 (15) added foo to x
+  @    618f8bd245a8 (15) added foo to x
   |\     rewritten(description, branch, content) from 45e15d6e88f5 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |    rewritten from 911c21adca13 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
@@ -283,11 +283,11 @@
   $ hg amend
 
   $ hg glog
-  @  19:0faa43228ee7 added y
+  @  19:bfe170c9c964 added y
   |   () [bar] draft
   | *  17:9c32d35206fb added y
   | |   () [default] draft
-  o |  15:4e844ab5e814 added foo to x
+  o |  15:618f8bd245a8 added foo to x
   | |   () [bar] draft
   o |  10:be5a8b9faa8a added d
   | |   () [default] draft
@@ -301,10 +301,10 @@
       () [default] draft
 
   $ hg evolve --content-divergent
-  merge:[19] added y
-  with: [17] added y
+  merge:[17] added y
+  with: [19] added y
   base: [16] added y
-  rebasing "other" content-divergent changeset 9c32d35206fb on 4e844ab5e814
+  rebasing "divergent" content-divergent changeset 9c32d35206fb on 618f8bd245a8
   merging y
   warning: conflicts while merging y! (edit, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
@@ -317,12 +317,12 @@
   (no more unresolved files)
   continue: hg evolve --continue
   $ hg evolve --continue
-  working directory is now at ba11a9f47a2e
+  working directory is now at 7411ed2cf7cf
 
   $ hg glog
-  @  21:ba11a9f47a2e added y
+  @  21:7411ed2cf7cf added y
   |   () [bar] draft
-  o  15:4e844ab5e814 added foo to x
+  o  15:618f8bd245a8 added foo to x
   |   () [bar] draft
   o  10:be5a8b9faa8a added d
   |   () [default] draft
@@ -346,29 +346,29 @@
   801b5920c7ea8d4ebdbc9cfc1e79e665dea2f211 5cf74a13db180e33dc2df8cd2aa70b21252a2a64 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '73', 'operation': 'amend', 'user': 'test'}
   801b5920c7ea8d4ebdbc9cfc1e79e665dea2f211 45e15d6e88f5bd23ba360dff0c7591eca2d99f43 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'}
   5cf74a13db180e33dc2df8cd2aa70b21252a2a64 911c21adca136894a2b35f0a58fae7ee94fa5e61 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'evolve', 'user': 'test'}
-  45e15d6e88f5bd23ba360dff0c7591eca2d99f43 4e844ab5e8142d26fb1f0990486379f2410b0358 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '73', 'operation': 'evolve', 'user': 'test'}
-  911c21adca136894a2b35f0a58fae7ee94fa5e61 4e844ab5e8142d26fb1f0990486379f2410b0358 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'evolve', 'user': 'test'}
+  911c21adca136894a2b35f0a58fae7ee94fa5e61 618f8bd245a8d1892954eb49a88a6ec5e500a5b5 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'evolve', 'user': 'test'}
+  45e15d6e88f5bd23ba360dff0c7591eca2d99f43 618f8bd245a8d1892954eb49a88a6ec5e500a5b5 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '73', 'operation': 'evolve', 'user': 'test'}
   ecf1d3992eb4d9700d441013fc4e89014692b461 9c32d35206fb5c3bf0ac814d410914d54a959a87 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
-  ecf1d3992eb4d9700d441013fc4e89014692b461 1bb9315961377c18863281be7634ec8ff9b73ea9 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '68', 'operation': 'rebase', 'user': 'test'}
-  1bb9315961377c18863281be7634ec8ff9b73ea9 0faa43228ee7fb9c993f076cef7e2ac14c85954b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
-  9c32d35206fb5c3bf0ac814d410914d54a959a87 0fc12918c8daa12ca83ce1e2a38e252b063b6276 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'evolve', 'user': 'test'}
-  0faa43228ee7fb9c993f076cef7e2ac14c85954b ba11a9f47a2e4a3380c4d5f80f64de41645a6681 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
-  0fc12918c8daa12ca83ce1e2a38e252b063b6276 ba11a9f47a2e4a3380c4d5f80f64de41645a6681 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '72', 'operation': 'evolve', 'user': 'test'}
+  ecf1d3992eb4d9700d441013fc4e89014692b461 491e9c6e22a4f265fad54d2060b9c2fa45f4301d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '68', 'operation': 'rebase', 'user': 'test'}
+  491e9c6e22a4f265fad54d2060b9c2fa45f4301d bfe170c9c96484157a071cd74e400426376c5e0e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
+  9c32d35206fb5c3bf0ac814d410914d54a959a87 7c47d5c3b6f5fb934723cdeb45c5819760988e1d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'evolve', 'user': 'test'}
+  7c47d5c3b6f5fb934723cdeb45c5819760988e1d 7411ed2cf7cfbc23f17711a72570787569177d69 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '72', 'operation': 'evolve', 'user': 'test'}
+  bfe170c9c96484157a071cd74e400426376c5e0e 7411ed2cf7cfbc23f17711a72570787569177d69 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
   $ hg obslog -r . --all
-  @    ba11a9f47a2e (21) added y
-  |\     amended(content) from 0faa43228ee7 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
-  | |    rewritten(branch, content) from 0fc12918c8da using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  @    7411ed2cf7cf (21) added y
+  |\     rewritten(branch, content) from 7c47d5c3b6f5 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |    amended(content) from bfe170c9c964 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
-  x |  0faa43228ee7 (19) added y
-  | |    amended(content) from 1bb931596137 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
-  | |
-  | x  0fc12918c8da (20) added y
+  x |  7c47d5c3b6f5 (20) added y
   | |    rebased(parent) from 9c32d35206fb using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
-  x |  1bb931596137 (18) added y
+  | x  bfe170c9c964 (19) added y
+  | |    amended(content) from 491e9c6e22a4 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |
+  | x  491e9c6e22a4 (18) added y
   | |    rewritten(branch, parent) from ecf1d3992eb4 using rebase by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
-  | x  9c32d35206fb (17) added y
+  x |  9c32d35206fb (17) added y
   |/     amended(content) from ecf1d3992eb4 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
   |
   x  ecf1d3992eb4 (16) added y
@@ -380,11 +380,11 @@
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 0fc12918c8daa12ca83ce1e2a38e252b063b6276
-  # Parent  4e844ab5e8142d26fb1f0990486379f2410b0358
+  # Node ID 7c47d5c3b6f5fb934723cdeb45c5819760988e1d
+  # Parent  618f8bd245a8d1892954eb49a88a6ec5e500a5b5
   added y
   
-  diff -r 4e844ab5e814 -r 0fc12918c8da y
+  diff -r 618f8bd245a8 -r 7c47d5c3b6f5 y
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/y	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
@@ -394,9 +394,9 @@
 ----------------------------------------------------------------------
 
   $ hg glog
-  @  21:ba11a9f47a2e added y
+  @  21:7411ed2cf7cf added y
   |   () [bar] draft
-  o  15:4e844ab5e814 added foo to x
+  o  15:618f8bd245a8 added foo to x
   |   () [bar] draft
   o  10:be5a8b9faa8a added d
   |   () [default] draft
@@ -436,13 +436,13 @@
   $ hg amend
 
   $ hg glog
-  @  25:ad2ec16eca1e added z
+  @  25:40a21b3496bc added z
   |   () [bar] draft
   | *  23:9bc2ace42175 added z
   | |   () [default] draft
-  o |  21:ba11a9f47a2e added y
+  o |  21:7411ed2cf7cf added y
   | |   () [bar] draft
-  o |  15:4e844ab5e814 added foo to x
+  o |  15:618f8bd245a8 added foo to x
   | |   () [bar] draft
   o |  10:be5a8b9faa8a added d
   | |   () [default] draft
@@ -456,10 +456,10 @@
       () [default] draft
 
   $ hg evolve --content-divergent --any
-  merge:[25] added z
-  with: [23] added z
+  merge:[23] added z
+  with: [25] added z
   base: [22] added z
-  rebasing "other" content-divergent changeset 9bc2ace42175 on ba11a9f47a2e
+  rebasing "divergent" content-divergent changeset 9bc2ace42175 on 7411ed2cf7cf
   merging y
   warning: conflicts while merging y! (edit, then use 'hg resolve --mark')
   unresolved merge conflicts
@@ -467,16 +467,16 @@
   [1]
 
   $ hg diff
-  diff -r ba11a9f47a2e y
+  diff -r 7411ed2cf7cf y
   --- a/y	Thu Jan 01 00:00:00 1970 +0000
   +++ b/y	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +1,5 @@
-  +<<<<<<< destination: ba11a9f47a2e bar - test: added y
+  +<<<<<<< destination: 7411ed2cf7cf bar - test: added y
    watbar
   +=======
   +foo
   +>>>>>>> evolving:    9bc2ace42175 - test: added z
-  diff -r ba11a9f47a2e z
+  diff -r 7411ed2cf7cf z
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/z	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
@@ -491,35 +491,41 @@
   evolving 23:9bc2ace42175 "added z"
   merging y
   warning: conflicts while merging y! (edit, then use 'hg resolve --mark')
-  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  1 files updated, 0 files merged, 0 files removed, 1 files unresolved
   unresolved merge conflicts
   (see 'hg help evolve.interrupted')
   [1]
 
   $ hg diff
-  diff -r ad2ec16eca1e y
+  diff -r 635c0edd2e45 y
   --- a/y	Thu Jan 01 00:00:00 1970 +0000
   +++ b/y	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +1,5 @@
-  +<<<<<<< local: ad2ec16eca1e bar - test: added z
-   watbar
+  +<<<<<<< local: 635c0edd2e45 - test: added z
+   foo
   +=======
-  +foo
-  +>>>>>>> other: a7326a078527 - test: added z
+  +watbar
+  +>>>>>>> other: 40a21b3496bc bar - test: added z
+  diff -r 635c0edd2e45 z
+  --- a/z	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/z	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -z
+  +bar
 
   $ echo foo > y
   $ hg resolve -m
   (no more unresolved files)
   continue: hg evolve --continue
   $ hg evolve --continue
-  working directory is now at 45e55c9ab3d0
+  working directory is now at 664febd074c2
 
   $ hg glog
-  @  27:45e55c9ab3d0 added z
+  @  27:664febd074c2 added z
   |   () [bar] draft
-  o  21:ba11a9f47a2e added y
+  o  21:7411ed2cf7cf added y
   |   () [bar] draft
-  o  15:4e844ab5e814 added foo to x
+  o  15:618f8bd245a8 added foo to x
   |   () [bar] draft
   o  10:be5a8b9faa8a added d
   |   () [default] draft
@@ -538,17 +544,17 @@
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
   # Branch bar
-  # Node ID 45e55c9ab3d0b4746161fcbe5b6c062eb4647fdb
-  # Parent  ba11a9f47a2e4a3380c4d5f80f64de41645a6681
+  # Node ID 664febd074c2f9c5c4e03045dd688e93360f297c
+  # Parent  7411ed2cf7cfbc23f17711a72570787569177d69
   added z
   
-  diff -r ba11a9f47a2e -r 45e55c9ab3d0 y
+  diff -r 7411ed2cf7cf -r 664febd074c2 y
   --- a/y	Thu Jan 01 00:00:00 1970 +0000
   +++ b/y	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +1,1 @@
   -watbar
   +foo
-  diff -r ba11a9f47a2e -r 45e55c9ab3d0 z
+  diff -r 7411ed2cf7cf -r 664febd074c2 z
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/z	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
@@ -565,36 +571,36 @@
   801b5920c7ea8d4ebdbc9cfc1e79e665dea2f211 5cf74a13db180e33dc2df8cd2aa70b21252a2a64 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '73', 'operation': 'amend', 'user': 'test'}
   801b5920c7ea8d4ebdbc9cfc1e79e665dea2f211 45e15d6e88f5bd23ba360dff0c7591eca2d99f43 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'}
   5cf74a13db180e33dc2df8cd2aa70b21252a2a64 911c21adca136894a2b35f0a58fae7ee94fa5e61 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'evolve', 'user': 'test'}
-  45e15d6e88f5bd23ba360dff0c7591eca2d99f43 4e844ab5e8142d26fb1f0990486379f2410b0358 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '73', 'operation': 'evolve', 'user': 'test'}
-  911c21adca136894a2b35f0a58fae7ee94fa5e61 4e844ab5e8142d26fb1f0990486379f2410b0358 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'evolve', 'user': 'test'}
+  911c21adca136894a2b35f0a58fae7ee94fa5e61 618f8bd245a8d1892954eb49a88a6ec5e500a5b5 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'evolve', 'user': 'test'}
+  45e15d6e88f5bd23ba360dff0c7591eca2d99f43 618f8bd245a8d1892954eb49a88a6ec5e500a5b5 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '73', 'operation': 'evolve', 'user': 'test'}
   ecf1d3992eb4d9700d441013fc4e89014692b461 9c32d35206fb5c3bf0ac814d410914d54a959a87 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
-  ecf1d3992eb4d9700d441013fc4e89014692b461 1bb9315961377c18863281be7634ec8ff9b73ea9 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '68', 'operation': 'rebase', 'user': 'test'}
-  1bb9315961377c18863281be7634ec8ff9b73ea9 0faa43228ee7fb9c993f076cef7e2ac14c85954b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
-  9c32d35206fb5c3bf0ac814d410914d54a959a87 0fc12918c8daa12ca83ce1e2a38e252b063b6276 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'evolve', 'user': 'test'}
-  0faa43228ee7fb9c993f076cef7e2ac14c85954b ba11a9f47a2e4a3380c4d5f80f64de41645a6681 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
-  0fc12918c8daa12ca83ce1e2a38e252b063b6276 ba11a9f47a2e4a3380c4d5f80f64de41645a6681 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '72', 'operation': 'evolve', 'user': 'test'}
+  ecf1d3992eb4d9700d441013fc4e89014692b461 491e9c6e22a4f265fad54d2060b9c2fa45f4301d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '68', 'operation': 'rebase', 'user': 'test'}
+  491e9c6e22a4f265fad54d2060b9c2fa45f4301d bfe170c9c96484157a071cd74e400426376c5e0e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
+  9c32d35206fb5c3bf0ac814d410914d54a959a87 7c47d5c3b6f5fb934723cdeb45c5819760988e1d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'evolve', 'user': 'test'}
+  7c47d5c3b6f5fb934723cdeb45c5819760988e1d 7411ed2cf7cfbc23f17711a72570787569177d69 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '72', 'operation': 'evolve', 'user': 'test'}
+  bfe170c9c96484157a071cd74e400426376c5e0e 7411ed2cf7cfbc23f17711a72570787569177d69 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
   2048a66e8834bda866dcc8c479f091897816833e 9bc2ace42175da7380251fca97730f62ff5b9185 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
-  2048a66e8834bda866dcc8c479f091897816833e ee19d6cc67048a1a7469268068a1413611720975 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '68', 'operation': 'rebase', 'user': 'test'}
-  ee19d6cc67048a1a7469268068a1413611720975 ad2ec16eca1eac4cf5045b496efa6205652e9a02 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
-  9bc2ace42175da7380251fca97730f62ff5b9185 a7326a0785271a7bef2e812a9a742fb4256b4a3c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'evolve', 'user': 'test'}
-  ad2ec16eca1eac4cf5045b496efa6205652e9a02 45e55c9ab3d0b4746161fcbe5b6c062eb4647fdb 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
-  a7326a0785271a7bef2e812a9a742fb4256b4a3c 45e55c9ab3d0b4746161fcbe5b6c062eb4647fdb 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '72', 'operation': 'evolve', 'user': 'test'}
+  2048a66e8834bda866dcc8c479f091897816833e 8bf0130be95ef72377e39232335531426c2abcf9 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '68', 'operation': 'rebase', 'user': 'test'}
+  8bf0130be95ef72377e39232335531426c2abcf9 40a21b3496bc55fd0c0ac92d81b2930cfa4d4bef 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
+  9bc2ace42175da7380251fca97730f62ff5b9185 635c0edd2e45de215b2061b30aae5168708238d3 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'evolve', 'user': 'test'}
+  635c0edd2e45de215b2061b30aae5168708238d3 664febd074c2f9c5c4e03045dd688e93360f297c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '72', 'operation': 'evolve', 'user': 'test'}
+  40a21b3496bc55fd0c0ac92d81b2930cfa4d4bef 664febd074c2f9c5c4e03045dd688e93360f297c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
   $ hg obslog --all
-  @    45e55c9ab3d0 (27) added z
-  |\     rewritten(branch, content) from a7326a078527 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
-  | |    amended(content) from ad2ec16eca1e using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  @    664febd074c2 (27) added z
+  |\     amended(content) from 40a21b3496bc using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |    rewritten(branch, content) from 635c0edd2e45 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
-  x |  a7326a078527 (26) added z
+  x |  40a21b3496bc (25) added z
+  | |    amended(content) from 8bf0130be95e using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |
+  | x  635c0edd2e45 (26) added z
   | |    rewritten(parent, content) from 9bc2ace42175 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
-  | x  ad2ec16eca1e (25) added z
-  | |    amended(content) from ee19d6cc6704 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+  x |  8bf0130be95e (24) added z
+  | |    rewritten(branch, parent) from 2048a66e8834 using rebase by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
-  x |  9bc2ace42175 (23) added z
-  | |    amended(content) from 2048a66e8834 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
-  | |
-  | x  ee19d6cc6704 (24) added z
-  |/     rewritten(branch, parent) from 2048a66e8834 using rebase by test (Thu Jan 01 00:00:00 1970 +0000)
+  | x  9bc2ace42175 (23) added z
+  |/     amended(content) from 2048a66e8834 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
   |
   x  2048a66e8834 (22) added z
   
--- a/tests/test-evolve-content-divergent-stack.t	Fri Sep 25 11:06:46 2020 -0700
+++ b/tests/test-evolve-content-divergent-stack.t	Sun Sep 20 09:22:04 2020 +0530
@@ -149,25 +149,28 @@
   with: [10] added b
   base: [2] added b
   rebasing "divergent" content-divergent changeset d5f148423c16 on df93a529fa42
+  rebasing "other" content-divergent changeset 88516dccf68a on df93a529fa42
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merge:[7] added c
   with: [11] added c
   base: [3] added c
-  rebasing "divergent" content-divergent changeset 3ce4be6d8e5e on 365f419742a3
+  rebasing "divergent" content-divergent changeset 3ce4be6d8e5e on aca5a88a1692
+  rebasing "other" content-divergent changeset 9e5fb1d5b955 on aca5a88a1692
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merge:[8] added d
   with: [12] added d
   base: [4] added d
-  rebasing "divergent" content-divergent changeset c72d2885eb51 on a18171c7d9e7
+  rebasing "divergent" content-divergent changeset c72d2885eb51 on 67e04919c9a4
+  rebasing "other" content-divergent changeset 15c781f93cac on 67e04919c9a4
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   working directory is now at df93a529fa42
 
   $ hg glog
-  o  19:59d49942cf47 added d
+  o  22:e72164a86fb4 added d
   |   () [default] draft
-  o  17:a18171c7d9e7 added c
+  o  19:67e04919c9a4 added c
   |   () [default] draft
-  o  15:365f419742a3 added b
+  o  16:aca5a88a1692 added b
   |   () [default] draft
   @  13:df93a529fa42 watbar to a
   |   () [default] draft
@@ -182,24 +185,24 @@
 merge conflict.
 
   $ hg log -r "desc('added c')" -p
-  changeset:   17:a18171c7d9e7
-  parent:      15:365f419742a3
+  changeset:   19:67e04919c9a4
+  parent:      16:aca5a88a1692
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     added c
   
-  diff -r 365f419742a3 -r a18171c7d9e7 c
+  diff -r aca5a88a1692 -r 67e04919c9a4 c
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/c	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
   +foo
   
-  $ hg strip -r 16: --hidden
-  saved backup bundle to $TESTTMP/stacktest/.hg/strip-backup/b949c7ad8d83-6039d2cc-backup.hg
+  $ hg strip -r 17: --hidden
+  saved backup bundle to $TESTTMP/stacktest/.hg/strip-backup/f1cd8f167491-3817ebd7-backup.hg
   4 new orphan changesets
   4 new content-divergent changesets
   $ hg glog
-  o  15:365f419742a3 added b
+  o  16:aca5a88a1692 added b
   |   () [default] draft
   @  13:df93a529fa42 watbar to a
   |   () [default] draft
@@ -223,7 +226,7 @@
       () [default] draft
   $ hg next
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  [15] added b
+  [16] added b
   $ echo conflict > c
   $ hg amend -A
   adding c
@@ -234,12 +237,37 @@
   $ echo new_file > newfile
   $ hg amend -Am "added c and newfile"
   adding newfile
+  $ hg glog
+  @  18:2ecfb60af48a added c and newfile
+  |   () [default] draft
+  | o  17:5907cbc074a0 added b
+  | |   () [default] draft
+  | o  13:df93a529fa42 watbar to a
+  | |   () [default] draft
+  | | *  12:15c781f93cac added d
+  | | |   () [default] draft
+  +---x  11:9e5fb1d5b955 added c
+  | |     () [default] draft
+  x |  10:88516dccf68a added b
+  | |   () [default] draft
+  x |  9:82b74d5dc678 watbar to a
+  |/    () [default] draft
+  | *  8:c72d2885eb51 added d
+  | |   () [default] draft
+  | *  7:3ce4be6d8e5e added c
+  | |   () [default] draft
+  | x  6:d5f148423c16 added b
+  | |   () [default] draft
+  | x  5:8e222f257bbf watbar to a
+  |/    () [default] draft
+  o  0:8fa14d15e168 added hgignore
+      () [default] draft
 
   $ hg evolve --content-divergent -r 7
   merge:[7] added c
-  with: [17] added c and newfile
+  with: [18] added c and newfile
   base: [3] added c
-  rebasing "divergent" content-divergent changeset 3ce4be6d8e5e on fb488ec29dfa
+  rebasing "divergent" content-divergent changeset 3ce4be6d8e5e on 5907cbc074a0
   merging c
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   unresolved merge conflicts
@@ -252,23 +280,52 @@
 
   $ hg evolve --continue
   evolving 7:3ce4be6d8e5e "added c"
+  rebasing "other" content-divergent changeset 2ecfb60af48a on 5907cbc074a0
+  merging c
+  warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
+  unresolved merge conflicts
+  (see 'hg help evolve.interrupted')
+  [1]
+  $ hg diff
+  diff -r 5907cbc074a0 c
+  --- a/c	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,5 @@
+  +<<<<<<< destination: 5907cbc074a0 - test: added b
+   conflict
+  +=======
+  +foo
+  +>>>>>>> evolving:    2ecfb60af48a - test: added c and newfile
+  diff -r 5907cbc074a0 newfile
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/newfile	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +new_file
+
+  $ echo c > c
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+  $ hg evolve -c
+  evolving 18:2ecfb60af48a "added c and newfile"
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 3d278b2f60ff
+  working directory is now at 7e8d59a0286a
+
   $ hg log -p -l1
-  changeset:   19:3d278b2f60ff
+  changeset:   21:7e8d59a0286a
   tag:         tip
-  parent:      16:fb488ec29dfa
+  parent:      17:5907cbc074a0
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     added c and newfile
   
-  diff -r fb488ec29dfa -r 3d278b2f60ff c
+  diff -r 5907cbc074a0 -r 7e8d59a0286a c
   --- a/c	Thu Jan 01 00:00:00 1970 +0000
   +++ b/c	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +1,1 @@
   -conflict
   +c
-  diff -r fb488ec29dfa -r 3d278b2f60ff newfile
+  diff -r 5907cbc074a0 -r 7e8d59a0286a newfile
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/newfile	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
@@ -413,39 +470,39 @@
       () [default] draft
 
   $ hg evolve --all --content-divergent
-  merge:[10] added a
-  with: [5] watbar to a
+  merge:[5] watbar to a
+  with: [10] added a
   base: [1] added a
-  rebasing "other" content-divergent changeset 8e222f257bbf on 2228e3b74514
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  merge:[11] added b
-  with: [6] added b
+  rebasing "divergent" content-divergent changeset 8e222f257bbf on 2228e3b74514
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  merge:[6] added b
+  with: [11] added b
   base: [2] added b
-  rebasing "divergent" content-divergent changeset 6eb54b5af3fb on ebb749d2ace8
-  rebasing "other" content-divergent changeset d5f148423c16 on ebb749d2ace8
+  rebasing "divergent" content-divergent changeset d5f148423c16 on 7e67dfb7ee31
+  rebasing "other" content-divergent changeset 6eb54b5af3fb on 7e67dfb7ee31
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  merge:[12] added c
-  with: [7] added c
+  merge:[7] added c
+  with: [12] added c
   base: [3] added c
-  rebasing "divergent" content-divergent changeset 8ed612937375 on 9437917ebe8d
-  rebasing "other" content-divergent changeset 3ce4be6d8e5e on 9437917ebe8d
+  rebasing "divergent" content-divergent changeset 3ce4be6d8e5e on 80cec1b1c90f
+  rebasing "other" content-divergent changeset 8ed612937375 on 80cec1b1c90f
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  merge:[13] added d
-  with: [8] added d
+  merge:[8] added d
+  with: [13] added d
   base: [4] added d
-  rebasing "divergent" content-divergent changeset d45f050514c2 on 8e574c12775a
-  rebasing "other" content-divergent changeset c72d2885eb51 on 8e574c12775a
+  rebasing "divergent" content-divergent changeset c72d2885eb51 on 7e370616fb2b
+  rebasing "other" content-divergent changeset d45f050514c2 on 7e370616fb2b
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at ebb749d2ace8
+  working directory is now at 7e67dfb7ee31
 
   $ hg glog
-  o  24:5ab9b88fbead added d
+  o  24:469255caf534 added d
   |   () [default] draft
-  o  21:8e574c12775a added c
+  o  21:7e370616fb2b added c
   |   () [default] draft
-  o  18:9437917ebe8d added b
+  o  18:80cec1b1c90f added b
   |   () [default] draft
-  @  15:ebb749d2ace8 watbar to a
+  @  15:7e67dfb7ee31 watbar to a
   |   () [default] draft
   o  9:2228e3b74514 add newfile
   |   () [default] draft
@@ -457,30 +514,43 @@
 
   $ hg strip 14: --hidden
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/stackrepo1/.hg/strip-backup/ebb749d2ace8-0585ef5a-backup.hg
+  saved backup bundle to $TESTTMP/stackrepo1/.hg/strip-backup/7e67dfb7ee31-ff5c6a6d-backup.hg
   8 new content-divergent changesets
 
 Prepare repo to have merge conflicts
   $ hg up -r "max(desc('added a'))"
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg evolve -r . --content-divergent
-  merge:[10] added a
-  with: [5] watbar to a
+  merge:[5] watbar to a
+  with: [10] added a
   base: [1] added a
-  rebasing "other" content-divergent changeset 8e222f257bbf on 2228e3b74514
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  rebasing "divergent" content-divergent changeset 8e222f257bbf on 2228e3b74514
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   6 new orphan changesets
-  working directory is now at ebb749d2ace8
+  working directory is now at 7e67dfb7ee31
   $ echo b_conflict > b
   $ hg amend -A
   adding b
 
 Let's try to evolve stack
   $ hg evolve --content-divergent
-  merge:[11] added b
-  with: [6] added b
+  merge:[6] added b
+  with: [11] added b
   base: [2] added b
-  rebasing "divergent" content-divergent changeset 6eb54b5af3fb on 73a960350ce9
+  rebasing "divergent" content-divergent changeset d5f148423c16 on c758af982013
+  merging b
+  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
+  unresolved merge conflicts
+  (see 'hg help evolve.interrupted')
+  [1]
+
+  $ echo b > b
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+  $ hg evolve --continue
+  evolving 6:d5f148423c16 "added b"
+  rebasing "other" content-divergent changeset 6eb54b5af3fb on c758af982013
   merging b
   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   unresolved merge conflicts
@@ -493,41 +563,28 @@
   continue: hg evolve --continue
   $ hg evolve --continue
   evolving 11:6eb54b5af3fb "added b"
-  rebasing "other" content-divergent changeset d5f148423c16 on 73a960350ce9
-  merging b
-  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
-  unresolved merge conflicts
-  (see 'hg help evolve.interrupted')
-  [1]
-
-  $ echo b > b
-  $ hg res -m
-  (no more unresolved files)
-  continue: hg evolve --continue
-  $ hg evolve --continue
-  evolving 6:d5f148423c16 "added b"
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  merge:[12] added c
-  with: [7] added c
+  merge:[7] added c
+  with: [12] added c
   base: [3] added c
-  rebasing "divergent" content-divergent changeset 8ed612937375 on 1b637ec00f24
-  rebasing "other" content-divergent changeset 3ce4be6d8e5e on 1b637ec00f24
+  rebasing "divergent" content-divergent changeset 3ce4be6d8e5e on 1a79fc84e761
+  rebasing "other" content-divergent changeset 8ed612937375 on 1a79fc84e761
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  merge:[13] added d
-  with: [8] added d
+  merge:[8] added d
+  with: [13] added d
   base: [4] added d
-  rebasing "divergent" content-divergent changeset d45f050514c2 on fbfadbe143d8
-  rebasing "other" content-divergent changeset c72d2885eb51 on fbfadbe143d8
+  rebasing "divergent" content-divergent changeset c72d2885eb51 on 6c228f1e5409
+  rebasing "other" content-divergent changeset d45f050514c2 on 6c228f1e5409
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 73a960350ce9
+  working directory is now at c758af982013
   $ hg glog
-  o  25:bf2836f524a3 added d
+  o  25:957008d45543 added d
   |   () [default] draft
-  o  22:fbfadbe143d8 added c
+  o  22:6c228f1e5409 added c
   |   () [default] draft
-  o  19:1b637ec00f24 added b
+  o  19:1a79fc84e761 added b
   |   () [default] draft
-  @  16:73a960350ce9 watbar to a
+  @  16:c758af982013 watbar to a
   |   () [default] draft
   o  9:2228e3b74514 add newfile
   |   () [default] draft
@@ -538,7 +595,7 @@
 --------------------------------------------------------------
   $ hg strip 14: --hidden
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/stackrepo1/.hg/strip-backup/ebb749d2ace8-c2c1e937-backup.hg
+  saved backup bundle to $TESTTMP/stackrepo1/.hg/strip-backup/c758af982013-0af4fee9-backup.hg
   8 new content-divergent changesets
 
 Insert conflicting changes in between the stack of content-div csets
@@ -571,16 +628,16 @@
   
 Now let's try to evolve stack
   $ hg evolve --content-divergent
-  merge:[10] added a
-  with: [5] watbar to a
+  merge:[5] watbar to a
+  with: [10] added a
   base: [1] added a
-  rebasing "other" content-divergent changeset 8e222f257bbf on 2228e3b74514
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  rebasing "divergent" content-divergent changeset 8e222f257bbf on 2228e3b74514
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merge:[14] added b
   with: [17] added b
   base: [2] added b
-  rebasing "divergent" content-divergent changeset 2a955e808c53 on ebb749d2ace8
-  rebasing "other" content-divergent changeset 509103439e5e on ebb749d2ace8
+  rebasing "divergent" content-divergent changeset 2a955e808c53 on 7e67dfb7ee31
+  rebasing "other" content-divergent changeset 509103439e5e on 7e67dfb7ee31
   merging b
   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
@@ -672,16 +729,16 @@
      summary:     added hgignore
   
   $ hg evolve --content-divergent
-  merge:[10] added a
-  with: [5] watbar to a
+  merge:[5] watbar to a
+  with: [10] added a
   base: [1] added a
-  rebasing "other" content-divergent changeset 8e222f257bbf on 2228e3b74514
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  rebasing "divergent" content-divergent changeset 8e222f257bbf on 2228e3b74514
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merge:[14] added b
   with: [17] added b
   base: [2] added b
-  rebasing "divergent" content-divergent changeset 2a955e808c53 on ebb749d2ace8
-  rebasing "other" content-divergent changeset 509103439e5e on ebb749d2ace8
+  rebasing "divergent" content-divergent changeset 2a955e808c53 on 7e67dfb7ee31
+  rebasing "other" content-divergent changeset 509103439e5e on 7e67dfb7ee31
   merging b
   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
@@ -695,7 +752,7 @@
   stopped the interrupted evolve
   working directory is now at 2a955e808c53
   $ hg log -G
-  o  changeset:   21:ebb749d2ace8
+  o  changeset:   21:7e67dfb7ee31
   |  tag:         tip
   |  parent:      9:2228e3b74514
   |  user:        test
@@ -743,7 +800,7 @@
   +---x  changeset:   10:c04ff147ef79
   | |    user:        test
   | |    date:        Thu Jan 01 00:00:00 1970 +0000
-  | |    obsolete:    rewritten using evolve as 21:ebb749d2ace8
+  | |    obsolete:    rewritten using evolve as 21:7e67dfb7ee31
   | |    summary:     added a
   | |
   o |  changeset:   9:2228e3b74514
@@ -756,7 +813,7 @@
   |/   parent:      0:8fa14d15e168
   |    user:        test
   |    date:        Thu Jan 01 00:00:00 1970 +0000
-  |    obsolete:    rebased using evolve as 21:ebb749d2ace8
+  |    obsolete:    rebased using evolve as 21:7e67dfb7ee31
   |    summary:     watbar to a
   |
   o  changeset:   0:8fa14d15e168
@@ -765,7 +822,7 @@
      summary:     added hgignore
   
   $ hg obslog -r 'desc("watbar to a")' --all
-  o    ebb749d2ace8 (21) watbar to a
+  o    7e67dfb7ee31 (21) watbar to a
   |\     rewritten from 186bdc2cdfa2 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |    rewritten(description, content) from c04ff147ef79 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
@@ -801,8 +858,8 @@
   merge:[14] added b
   with: [17] added b
   base: [2] added b
-  rebasing "divergent" content-divergent changeset 2a955e808c53 on ebb749d2ace8
-  rebasing "other" content-divergent changeset 509103439e5e on ebb749d2ace8
+  rebasing "divergent" content-divergent changeset 2a955e808c53 on 7e67dfb7ee31
+  rebasing "other" content-divergent changeset 509103439e5e on 7e67dfb7ee31
   merging b
   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
@@ -818,16 +875,16 @@
   merge:[15] added c
   with: [18] added c
   base: [3] added c
-  rebasing "divergent" content-divergent changeset 48b0f803817a on 32bceb5bc91e
-  rebasing "other" content-divergent changeset eaf34afe4df3 on 32bceb5bc91e
+  rebasing "divergent" content-divergent changeset 48b0f803817a on ddfcba2aac91
+  rebasing "other" content-divergent changeset eaf34afe4df3 on ddfcba2aac91
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merge:[16] added d
   with: [19] added d
   base: [4] added d
-  rebasing "divergent" content-divergent changeset 91c8ccb9c241 on a87eb9f90df6
-  rebasing "other" content-divergent changeset c351be27f199 on a87eb9f90df6
+  rebasing "divergent" content-divergent changeset 91c8ccb9c241 on bb396302d792
+  rebasing "other" content-divergent changeset c351be27f199 on bb396302d792
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 32bceb5bc91e
+  working directory is now at ddfcba2aac91
 
   $ hg evolve -l
 
@@ -954,16 +1011,16 @@
   
 
   $ hg evolve --content-divergent
-  merge:[6] b
-  with: [3] b
+  merge:[3] b
+  with: [6] b
   base: [1] b
-  rebasing "other" content-divergent changeset 5b2d00df9c4e on 980f7dc84c29
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  merge:[7] c
-  with: [4] c
+  rebasing "divergent" content-divergent changeset 5b2d00df9c4e on 980f7dc84c29
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  merge:[4] c
+  with: [7] c
   base: [2] c
-  rebasing "divergent" content-divergent changeset ef4885dea3da on 6813d99f0a9d
-  rebasing "other" content-divergent changeset fef59171875e on 6813d99f0a9d
+  rebasing "divergent" content-divergent changeset fef59171875e on bfba946a2829
+  rebasing "other" content-divergent changeset ef4885dea3da on bfba946a2829
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Expected result:
@@ -971,15 +1028,15 @@
 Changeset with description "c" only adds file "c" with content "c".
 
   $ hg glog -l2 -p
-  o  12:d5a8159e883f c
-  |   () [default] draftdiff -r 6813d99f0a9d -r d5a8159e883f c
+  o  12:a5abd6c7f9d8 c
+  |   () [default] draftdiff -r bfba946a2829 -r a5abd6c7f9d8 c
   |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   |  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
   |  @@ -0,0 +1,1 @@
   |  +c
   |
-  o  9:6813d99f0a9d b
-  |   () [default] draftdiff -r 980f7dc84c29 -r 6813d99f0a9d b
+  o  9:bfba946a2829 b
+  |   () [default] draftdiff -r 980f7dc84c29 -r bfba946a2829 b
   ~  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
      +++ b/b	Thu Jan 01 00:00:00 1970 +0000
      @@ -0,0 +1,1 @@
@@ -1057,24 +1114,24 @@
       () [default] draft
 
   $ hg evolve -r 4+5 --content-divergent
-  merge:[8] added foo
-  with: [4] added foo
+  merge:[4] added foo
+  with: [8] added foo
   base: [1] added foo
-  rebasing "other" content-divergent changeset 8a2d93492f59 on 9703820a7d5b
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  merge:[9] added bar and car
-  with: [5] added bar and car
+  rebasing "divergent" content-divergent changeset 8a2d93492f59 on 9703820a7d5b
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  merge:[5] added bar and car
+  with: [9] added bar and car
   base: [2] added bar and car
-  rebasing "divergent" content-divergent changeset 7dd5b9d42ef3 on 586526ab82c5
-  rebasing "other" content-divergent changeset f4ed107810a7 on 586526ab82c5
+  rebasing "divergent" content-divergent changeset f4ed107810a7 on 3e0693d8f69b
+  rebasing "other" content-divergent changeset 7dd5b9d42ef3 on 3e0693d8f69b
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   2 new orphan changesets
-  working directory is now at 586526ab82c5
+  working directory is now at 3e0693d8f69b
 
   $ hg glog
-  o  15:e905bb19fd7e added bar and car
+  o  15:5382795441b8 added bar and car
   |   () [default] draft
-  @  12:586526ab82c5 added foo
+  @  12:3e0693d8f69b added foo
   |   () [default] draft
   | *  10:9a1f460df8b5 added dar
   | |   () [default] draft
--- a/tests/test-evolve-issue5958.t	Fri Sep 25 11:06:46 2020 -0700
+++ b/tests/test-evolve-issue5958.t	Sun Sep 20 09:22:04 2020 +0530
@@ -89,11 +89,12 @@
   merge:[4] add foo.txt
   with: [6] add foo.txt
   base: [1] add foo.txt
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 17e66b2fbf1b
+  rebasing "other" content-divergent changeset 08bc7ba82799 on a24ed8ad918c
+  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  working directory is now at d519bd54a945
 
   $ hg log -G
-  @  changeset:   7:17e66b2fbf1b
+  @  changeset:   8:d519bd54a945
   |  tag:         tip
   |  parent:      0:a24ed8ad918c
   |  user:        test
@@ -108,19 +109,19 @@
 test that resolution is consistent and independent of divergent changeset we initiate the resolution from
 
   $ hg strip . --config extensions.strip=
-  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
-  saved backup bundle to $TESTTMP/issue5958/.hg/strip-backup/17e66b2fbf1b-080f2943-backup.hg
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  saved backup bundle to $TESTTMP/issue5958/.hg/strip-backup/d519bd54a945-5f6b2f65-backup.hg
   2 new content-divergent changesets
   $ hg up 4
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg evolve --content-divergent
   merge:[4] add foo.txt
-  with: [6] add foo.txt
+  with: [7] add foo.txt
   base: [1] add foo.txt
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 17e66b2fbf1b
+  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  working directory is now at d519bd54a945
   $ hg log -G
-  @  changeset:   7:17e66b2fbf1b
+  @  changeset:   8:d519bd54a945
   |  tag:         tip
   |  parent:      0:a24ed8ad918c
   |  user:        test