evolve: create a new commit instead of amending one of the divergents
authorPulkit Goyal <7895pulkit@gmail.com>
Wed, 13 Jun 2018 17:15:10 +0530
changeset 3846 f9dad99a90d5
parent 3845 5c964ebe4d4b
child 3847 8bad32e1e6c1
evolve: create a new commit instead of amending one of the divergents This patch changes the behavior of evolve command while resolving content-divergence to create a new commit instead of amending one of the divergent ones. In past, I have made this change, backed out this change and now today again I am doing this change, so let's dive in some history. Using cmdrewrite.amend() was never a good option as that requires hack to delete the evolvestate and also gives us less control over things. We can't make the commit on top of different parents as that of content-divergent ones. Due to all these, I first made this change to create a new commit instead of amending one. But, after few days, there was flakiness observed in the tests and turned out that we need to do some dirstate dance as repo.dirstate.setparents() does not always fix the dirstate. That flakiness was a blocker for progress at that time and we decided to switch to amend back so that we can have things working with some hacks and we can later fix the implementation part. Now, yesterday while tackling resolving content-divergence of a stack which is as follows: C1 C2 | | B1 B2 | | A1 A2 \/ base where, A1-A2, B1-B2, C1-C2 are content-divergent with each other. Now we can resolve A1-A2 very well because they have the same parent and let's say that resolution leads to A3. Now, we want to resolve B1-B2 and make the new resolution commit on top of A3 so that we can end up something like: C3 | B3 | A3 | base however, amending one of the divergent changesets, it's not possible to create a commit on a different parent like A3 here without some relocation. We should prevent relocation as that may leads to some conflicts and should change the parent before committing. So, looking ahead, we can't move with using amend as still using that we will need some relocation hacks making code ugly and prone to bad behaviors, bugs. Let's change back to creating a new commit so that we can move forward in a good way. About repo.dirstate.setparents() not setting the dirstate, I have researched yesterday night about how we can do that and found out that we can use cmdrewrite._uncommitdirstate() here. Expect upcoming patches to improve the documentation of that function. There are lot of test changes because of change in hash but there is no behavior change. The only behavior change is in test-evolve-abort-contentdiv.t which is nice because creating a new commit helps us in stripping that while aborting. We have a lot of testing of content-divergence and no behavior change gives enough confidence for making this change. I reviewed the patch carefully to make sure there is no behavior change and I suggest reviewer to do the same.
hgext3rd/evolve/evolvecmd.py
tests/test-divergent.t
tests/test-evolve-abort-contentdiv.t
tests/test-evolve-content-divergence.t
tests/test-sharing.t
tests/test-stabilize-result.t
--- a/hgext3rd/evolve/evolvecmd.py	Tue Jun 12 23:20:54 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Wed Jun 13 17:15:10 2018 +0530
@@ -515,13 +515,10 @@
     # whether to store the obsmarker in the evolvestate
     storemarker = False
     try:
-        repo.ui.setconfig('ui', 'allowemptycommit', True, 'evolve')
         with repo.dirstate.parentchange():
-            repo.dirstate.setparents(divergent.node(), node.nullid)
-        oldlen = len(repo)
-        # temporary hack because we can't use cmdrewrite.amend() during an
-        # interrupted evolve
-        evolvestate.delete()
+            repo.dirstate.setparents(divergent.p1().node(), node.nullid)
+
+        cmdrewrite._uncommitdirstate(repo, divergent, None, True)
 
         # merge the branches
         mergebranches(repo, divergent, other, base)
@@ -545,16 +542,18 @@
         # new node if any formed as the replacement
         newnode = None
 
-        # XXX: we should not use amend here, rather create a new commit
-        cmdrewrite.amend(ui, repo, message=desc, logfile='')
-        # XXX: we can get rid of this len() call also by creating a new commit
-        if oldlen == len(repo):
+        newnode = repo.commit(text=desc, user=repo.ui.username())
+        if newnode == divergent.node() or newnode is None:
             # no changes
             new = divergent
             storemarker = True
+            repo.ui.status(_("nothing changed\n"))
+            hg.updaterepo(repo, divergent.rev(), False)
         else:
-            new = repo['.']
+            new = repo[newnode]
             newnode = new.node()
+            hg.updaterepo(repo, new.rev(), False)
+            obsolete.createmarkers(repo, [(divergent, (new,))], operation='evolve')
 
         # creating markers and moving phases post-resolution
         obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
@@ -564,6 +563,7 @@
             # want to store more data and serialize obsmarker in a better way in
             # future
             evolvestate['obsmarkers'].append((other.node(), new.node()))
+
         phases.retractboundary(repo, tr, other.phase(), [new.node()])
         return (True, newnode)
     finally:
--- a/tests/test-divergent.t	Tue Jun 12 23:20:54 2018 +0530
+++ b/tests/test-divergent.t	Wed Jun 13 17:15:10 2018 +0530
@@ -72,9 +72,9 @@
   updating to "local" side of the conflict: 593c57f2117e
   merging "other" content-divergent changeset '8374d2ddc3a4'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at d52878315036
+  working directory is now at 45bf1312f454
   $ hg log -G
-  @  4:d52878315036@default(draft) divergent []
+  @  4:45bf1312f454@default(draft) divergent []
   |
   o  0:9092f1db7931@default(draft) added a []
   
@@ -106,7 +106,7 @@
   |/
   | o  5:48819a835615@default(draft) add _c []
   |/
-  | o  4:d52878315036@default(draft) divergent []
+  | o  4:45bf1312f454@default(draft) divergent []
   |/
   o  0:9092f1db7931@default(draft) added a []
   
@@ -122,7 +122,7 @@
   |
   | *  6:e3ff64ce8d4c@default(draft) add cdivergent1 [content-divergent]
   |/
-  | o  4:d52878315036@default(draft) divergent []
+  | o  4:45bf1312f454@default(draft) divergent []
   |/
   o  0:9092f1db7931@default(draft) added a []
   
@@ -202,6 +202,6 @@
   base: [1] add _b
   merging "other" content-divergent changeset '05a6b6a9e633'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 1155f059af3f
+  working directory is now at 73ff357d3975
 
   $ cd ..
--- a/tests/test-evolve-abort-contentdiv.t	Tue Jun 12 23:20:54 2018 +0530
+++ b/tests/test-evolve-abort-contentdiv.t	Wed Jun 13 17:15:10 2018 +0530
@@ -169,7 +169,6 @@
   updating to "local" side of the conflict: 2ba73e31f264
   merging "other" content-divergent changeset '491e10505bae'
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  nothing changed
   merge:[5] added d
   with: [7] added d
   base: [4] added d
@@ -182,6 +181,7 @@
   [255]
 
   $ hg evolve --abort
+  2 new content-divergent changesets
   evolve aborted
   working directory is now at 491e10505bae
 
--- a/tests/test-evolve-content-divergence.t	Tue Jun 12 23:20:54 2018 +0530
+++ b/tests/test-evolve-content-divergence.t	Wed Jun 13 17:15:10 2018 +0530
@@ -73,10 +73,10 @@
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   content divergent changesets on different branches.
   choose branch for the resolution changeset. (a) default or (b) watwat or (c) foobar?  c
-  working directory is now at 23a4467c278e
+  working directory is now at 0ac42f1bc15c
 
   $ hg glog
-  @  7:23a4467c278e added d
+  @  7:0ac42f1bc15c added d
   |   () [foobar] draft
   o  3:ca1b80f7960a added c
   |   () [default] draft
@@ -102,14 +102,14 @@
   $ echo bar > d
   $ hg ci -Aqm "added a d with bar in it, expect some beers"
 
-  $ hg prune -r 23a4467c278e -s . --hidden
+  $ hg prune -r 0ac42f1bc15c -s . --hidden
   1 changesets pruned
   2 new content-divergent changesets
 
   $ hg glog
   @  9:59081c9c425a added a d with bar in it, expect some beers
   |   () [default] draft
-  | *  8:36618f77f252 added d
+  | *  8:f621d00f5f0e added d
   |/    () [foobar] draft
   o  3:ca1b80f7960a added c
   |   () [default] draft
@@ -124,12 +124,12 @@
   merge:[9] added a d with bar in it, expect some beers
   with: [8] added d
   base: [7] added d
-  merging "other" content-divergent changeset '36618f77f252'
+  merging "other" content-divergent changeset 'f621d00f5f0e'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at ca80aeaf4ee8
+  working directory is now at a9d6fd6b5e40
 
   $ hg glog
-  @  10:ca80aeaf4ee8 added a d with bar in it, expect some beers
+  @  10:a9d6fd6b5e40 added a d with bar in it, expect some beers
   |   () [default] draft
   o  3:ca1b80f7960a added c
   |   () [default] draft
@@ -145,20 +145,20 @@
   $ echo foo > d
   $ hg amend -m "foo to d"
 
-  $ hg up ca80aeaf4ee8 --hidden
+  $ hg up a9d6fd6b5e40 --hidden
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  updated to hidden changeset ca80aeaf4ee8
-  (hidden revision 'ca80aeaf4ee8' was rewritten as: eba0b02801cb)
-  working directory parent is obsolete! (ca80aeaf4ee8)
-  (use 'hg evolve' to update to its successor: eba0b02801cb)
+  updated to hidden changeset a9d6fd6b5e40
+  (hidden revision 'a9d6fd6b5e40' was rewritten as: b10b07a394f1)
+  working directory parent is obsolete! (a9d6fd6b5e40)
+  (use 'hg evolve' to update to its successor: b10b07a394f1)
   $ echo babar > d
   $ hg amend -m "foo to d"
   2 new content-divergent changesets
 
   $ hg glog
-  @  12:0116315a1a4a foo to d
+  @  12:0bb497fed24a foo to d
   |   () [default] draft
-  | *  11:eba0b02801cb foo to d
+  | *  11:b10b07a394f1 foo to d
   |/    () [default] draft
   o  3:ca1b80f7960a added c
   |   () [default] draft
@@ -173,7 +173,7 @@
   merge:[12] foo to d
   with: [11] foo to d
   base: [10] added a d with bar in it, expect some beers
-  merging "other" content-divergent changeset 'eba0b02801cb'
+  merging "other" content-divergent changeset 'b10b07a394f1'
   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
@@ -185,10 +185,10 @@
   (no more unresolved files)
   continue: hg evolve --continue
   $ hg evolve --continue
-  working directory is now at 3e0a8df515d6
+  working directory is now at 11175423b5dc
 
   $ hg glog
-  @  13:3e0a8df515d6 foo to d
+  @  13:11175423b5dc foo to d
   |   () [default] draft
   o  3:ca1b80f7960a added c
   |   () [default] draft
@@ -205,20 +205,20 @@
   $ echo bar > d
   $ hg amend -m "bar to d, expect beers"
 
-  $ hg up 3e0a8df515d6 --hidden
+  $ hg up 11175423b5dc --hidden
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  updated to hidden changeset 3e0a8df515d6
-  (hidden revision '3e0a8df515d6' was rewritten as: 9ad4721c9004)
-  working directory parent is obsolete! (3e0a8df515d6)
-  (use 'hg evolve' to update to its successor: 9ad4721c9004)
+  updated to hidden changeset 11175423b5dc
+  (hidden revision '11175423b5dc' was rewritten as: 27f0463f169a)
+  working directory parent is obsolete! (11175423b5dc)
+  (use 'hg evolve' to update to its successor: 27f0463f169a)
   $ echo wat > d
   $ hg amend -m "wat to d, wat?"
   2 new content-divergent changesets
 
   $ hg glog
-  @  15:1e834b60df1b wat to d, wat?
+  @  15:f542037ddf31 wat to d, wat?
   |   () [default] draft
-  | *  14:9ad4721c9004 bar to d, expect beers
+  | *  14:27f0463f169a bar to d, expect beers
   |/    () [default] draft
   o  3:ca1b80f7960a added c
   |   () [default] draft
@@ -233,7 +233,7 @@
   merge:[15] wat to d, wat?
   with: [14] bar to d, expect beers
   base: [13] foo to d
-  merging "other" content-divergent changeset '9ad4721c9004'
+  merging "other" content-divergent changeset '27f0463f169a'
   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
@@ -268,10 +268,10 @@
   
   **done showing editors text**
   
-  working directory is now at 00f8d08aea43
+  working directory is now at 89ea3eee2d69
 
   $ hg glog
-  @  16:00f8d08aea43 watbar to d
+  @  16:89ea3eee2d69 watbar to d
   |   () [default] draft
   o  3:ca1b80f7960a added c
   |   () [default] draft
@@ -341,10 +341,10 @@
   updating to "local" side of the conflict: 7ed0642d644b
   merging "other" content-divergent changeset '11f849d7159f'
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  nothing changed
+  working directory is now at 171614c9a791
 
   $ hg glog
-  @  5:7ed0642d644b added b
+  @  8:171614c9a791 added b
   |   () [default] draft
   | *  4:c41c793e0ef1 added d
   | |   () [default] draft
@@ -362,11 +362,11 @@
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 7ed0642d644bb9ad93d252dd9ffe7b4729febe48
+  # Node ID 171614c9a7914c53f531373b95632323fdbbac8d
   # Parent  c7586e2a92645e473645847a7b69a6dc52be4276
   added b
   
-  diff -r c7586e2a9264 -r 7ed0642d644b b
+  diff -r c7586e2a9264 -r 171614c9a791 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 @@
@@ -376,16 +376,16 @@
 
   $ hg evolve --all
   move:[3] added c
-  atop:[5] added b
+  atop:[8] added b
   move:[4] added d
-  atop:[8] added c
-  working directory is now at b6b20b8eefdc
+  atop:[9] added c
+  working directory is now at 4ae4427ee9f8
   $ hg glog
-  @  9:b6b20b8eefdc added d
+  @  10:4ae4427ee9f8 added d
   |   () [default] draft
-  o  8:7c46f743e62f added c
+  o  9:917281f93fcb added c
   |   () [default] draft
-  o  5:7ed0642d644b added b
+  o  8:171614c9a791 added b
   |   () [default] draft
   o  1:c7586e2a9264 added a
   |   () [default] draft
@@ -399,7 +399,7 @@
   $ echo x > x
   $ hg ci -Aqm "added x"
   $ hg glog -r .
-  @  10:cfae5f87cd34 added x
+  @  11:71a392c714b5 added x
   |   () [default] draft
   ~
 
@@ -409,26 +409,26 @@
   (branches are permanent and global, did you want a bookmark?)
   $ hg amend -m "added foo to x"
 
-  $ hg up cfae5f87cd34 --hidden
+  $ hg up 71a392c714b5 --hidden
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  updated to hidden changeset cfae5f87cd34
-  (hidden revision 'cfae5f87cd34' was rewritten as: 580d9d182d90)
-  working directory parent is obsolete! (cfae5f87cd34)
-  (use 'hg evolve' to update to its successor: 580d9d182d90)
-  $ hg rebase -r . -d b6b20b8eefdc --config experimental.evolution.allowdivergence=True
-  rebasing 10:cfae5f87cd34 "added x"
+  updated to hidden changeset 71a392c714b5
+  (hidden revision '71a392c714b5' was rewritten as: 1e1a50385a7d)
+  working directory parent is obsolete! (71a392c714b5)
+  (use 'hg evolve' to update to its successor: 1e1a50385a7d)
+  $ hg rebase -r . -d 4ae4427ee9f8 --config experimental.evolution.allowdivergence=True
+  rebasing 11:71a392c714b5 "added x"
   2 new content-divergent changesets
 
   $ hg glog
-  @  12:c4d1990428e3 added x
+  @  13:1e4f6b3bb39b added x
   |   () [default] draft
-  | *  11:580d9d182d90 added foo to x
+  | *  12:1e1a50385a7d added foo to x
   | |   () [bar] draft
-  o |  9:b6b20b8eefdc added d
+  o |  10:4ae4427ee9f8 added d
   | |   () [default] draft
-  o |  8:7c46f743e62f added c
+  o |  9:917281f93fcb added c
   |/    () [default] draft
-  o  5:7ed0642d644b added b
+  o  8:171614c9a791 added b
   |   () [default] draft
   o  1:c7586e2a9264 added a
   |   () [default] draft
@@ -436,14 +436,14 @@
       () [default] draft
 
   $ hg evolve --content-divergent
-  merge:[12] added x
-  with: [11] added foo to x
-  base: [10] added x
-  rebasing "other" content-divergent changeset 580d9d182d90 on b6b20b8eefdc
-  updating to "local" side of the conflict: c4d1990428e3
-  merging "other" content-divergent changeset 'd3bfc0b3f350'
+  merge:[13] added x
+  with: [12] added foo to x
+  base: [11] added x
+  rebasing "other" content-divergent changeset 1e1a50385a7d on 4ae4427ee9f8
+  updating to "local" side of the conflict: 1e4f6b3bb39b
+  merging "other" content-divergent changeset '80cc9b1ec650'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at be41fdcd0ee1
+  working directory is now at b006cf317e0e
 
   $ hg exp
   # HG changeset patch
@@ -451,11 +451,11 @@
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
   # Branch bar
-  # Node ID be41fdcd0ee181081c4e42c6ee333d3dc3b3ab45
-  # Parent  b6b20b8eefdce1f32126c71d20bdb72a62b38268
+  # Node ID b006cf317e0ed16dbe786c439577475580f645f1
+  # Parent  4ae4427ee9f8f0935211fd66360948b77ab5aee9
   added foo to x
   
-  diff -r b6b20b8eefdc -r be41fdcd0ee1 x
+  diff -r 4ae4427ee9f8 -r b006cf317e0e 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 @@
@@ -464,13 +464,13 @@
 The above `hg exp` and the following log call demonstrates that message, content
 and branch change is preserved in case of relocation
   $ hg glog
-  @  14:be41fdcd0ee1 added foo to x
+  @  15:b006cf317e0e added foo to x
   |   () [bar] draft
-  o  9:b6b20b8eefdc added d
+  o  10:4ae4427ee9f8 added d
   |   () [default] draft
-  o  8:7c46f743e62f added c
+  o  9:917281f93fcb added c
   |   () [default] draft
-  o  5:7ed0642d644b added b
+  o  8:171614c9a791 added b
   |   () [default] draft
   o  1:c7586e2a9264 added a
   |   () [default] draft
@@ -487,37 +487,37 @@
   $ echo y > y
   $ hg ci -Aqm "added y"
   $ hg glog -r .
-  @  15:9c30046901ab added y
+  @  16:fc6ad2bac162 added y
   |   () [default] draft
   ~
 
   $ echo bar > y
   $ hg amend
 
-  $ hg up 9c30046901ab --hidden
+  $ hg up fc6ad2bac162 --hidden
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  updated to hidden changeset 9c30046901ab
-  (hidden revision '9c30046901ab' was rewritten as: 29e08829c51f)
-  working directory parent is obsolete! (9c30046901ab)
-  (use 'hg evolve' to update to its successor: 29e08829c51f)
-  $ hg rebase -r . -d be41fdcd0ee1 --config experimental.evolution.allowdivergence=True
-  rebasing 15:9c30046901ab "added y"
+  updated to hidden changeset fc6ad2bac162
+  (hidden revision 'fc6ad2bac162' was rewritten as: 2a9f6ccbdeba)
+  working directory parent is obsolete! (fc6ad2bac162)
+  (use 'hg evolve' to update to its successor: 2a9f6ccbdeba)
+  $ hg rebase -r . -d b006cf317e0e --config experimental.evolution.allowdivergence=True
+  rebasing 16:fc6ad2bac162 "added y"
   2 new content-divergent changesets
   $ echo wat > y
   $ hg amend
 
   $ hg glog
-  @  18:4065e1d314c3 added y
+  @  19:b4575ed6fcfc added y
   |   () [bar] draft
-  | *  16:29e08829c51f added y
+  | *  17:2a9f6ccbdeba added y
   | |   () [default] draft
-  o |  14:be41fdcd0ee1 added foo to x
+  o |  15:b006cf317e0e added foo to x
   | |   () [bar] draft
-  o |  9:b6b20b8eefdc added d
+  o |  10:4ae4427ee9f8 added d
   | |   () [default] draft
-  o |  8:7c46f743e62f added c
+  o |  9:917281f93fcb added c
   |/    () [default] draft
-  o  5:7ed0642d644b added b
+  o  8:171614c9a791 added b
   |   () [default] draft
   o  1:c7586e2a9264 added a
   |   () [default] draft
@@ -525,12 +525,12 @@
       () [default] draft
 
   $ hg evolve --content-divergent
-  merge:[18] added y
-  with: [16] added y
-  base: [15] added y
-  rebasing "other" content-divergent changeset 29e08829c51f on be41fdcd0ee1
-  updating to "local" side of the conflict: 4065e1d314c3
-  merging "other" content-divergent changeset '6d515d1ffc69'
+  merge:[19] added y
+  with: [17] added y
+  base: [16] added y
+  rebasing "other" content-divergent changeset 2a9f6ccbdeba on b006cf317e0e
+  updating to "local" side of the conflict: b4575ed6fcfc
+  merging "other" content-divergent changeset '48f745db3f53'
   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
@@ -542,18 +542,18 @@
   (no more unresolved files)
   continue: hg evolve --continue
   $ hg evolve --continue
-  working directory is now at bbaca013758a
+  working directory is now at 7bbcf24ddecf
 
   $ hg glog
-  @  20:bbaca013758a added y
+  @  21:7bbcf24ddecf added y
   |   () [bar] draft
-  o  14:be41fdcd0ee1 added foo to x
+  o  15:b006cf317e0e added foo to x
   |   () [bar] draft
-  o  9:b6b20b8eefdc added d
+  o  10:4ae4427ee9f8 added d
   |   () [default] draft
-  o  8:7c46f743e62f added c
+  o  9:917281f93fcb added c
   |   () [default] draft
-  o  5:7ed0642d644b added b
+  o  8:171614c9a791 added b
   |   () [default] draft
   o  1:c7586e2a9264 added a
   |   () [default] draft
@@ -561,36 +561,36 @@
       () [default] draft
 
   $ hg obslog -r . --all
-  @    bbaca013758a (20) added y
+  @    7bbcf24ddecf (21) added y
   |\
-  x |  4065e1d314c3 (18) added y
-  | |    rewritten(content) as bbaca013758a using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+  x |  48f745db3f53 (20) added y
+  | |    rewritten(branch, content) as 7bbcf24ddecf using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
-  | x  6d515d1ffc69 (19) added y
-  | |    rewritten(branch, content) as bbaca013758a using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | x  b4575ed6fcfc (19) added y
+  | |    rewritten(content) as 7bbcf24ddecf using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
-  | x  29e08829c51f (16) added y
-  | |    rewritten(parent) as 6d515d1ffc69 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  x |  2a9f6ccbdeba (17) added y
+  | |    rewritten(parent) as 48f745db3f53 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
-  x |  f1d75198aac4 (17) added y
-  |/     rewritten(content) as 4065e1d314c3 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+  | x  96b677f01b81 (18) added y
+  |/     rewritten(content) as b4575ed6fcfc using amend by test (Thu Jan 01 00:00:00 1970 +0000)
   |
-  x  9c30046901ab (15) added y
-       rewritten(content) as 29e08829c51f using amend by test (Thu Jan 01 00:00:00 1970 +0000)
-       rewritten(branch, parent) as f1d75198aac4 using rebase by test (Thu Jan 01 00:00:00 1970 +0000)
+  x  fc6ad2bac162 (16) added y
+       rewritten(content) as 2a9f6ccbdeba using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+       rewritten(branch, parent) as 96b677f01b81 using rebase by test (Thu Jan 01 00:00:00 1970 +0000)
   
 
 checking that relocated commit is there
-  $ hg exp 6d515d1ffc69 --hidden
+  $ hg exp 48f745db3f53 --hidden
   # HG changeset patch
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 6d515d1ffc6925b036c933078ccb804c26da80b2
-  # Parent  be41fdcd0ee181081c4e42c6ee333d3dc3b3ab45
+  # Node ID 48f745db3f5300363ca248b9aeab20ff2a55fbb3
+  # Parent  b006cf317e0ed16dbe786c439577475580f645f1
   added y
   
-  diff -r be41fdcd0ee1 -r 6d515d1ffc69 y
+  diff -r b006cf317e0e -r 48f745db3f53 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 @@
@@ -600,15 +600,15 @@
 ----------------------------------------------------------------------
 
   $ hg glog
-  @  20:bbaca013758a added y
+  @  21:7bbcf24ddecf added y
   |   () [bar] draft
-  o  14:be41fdcd0ee1 added foo to x
+  o  15:b006cf317e0e added foo to x
   |   () [bar] draft
-  o  9:b6b20b8eefdc added d
+  o  10:4ae4427ee9f8 added d
   |   () [default] draft
-  o  8:7c46f743e62f added c
+  o  9:917281f93fcb added c
   |   () [default] draft
-  o  5:7ed0642d644b added b
+  o  8:171614c9a791 added b
   |   () [default] draft
   o  1:c7586e2a9264 added a
   |   () [default] draft
@@ -621,7 +621,7 @@
   $ echo z > z
   $ hg ci -Aqm "added z"
   $ hg glog -r .
-  @  21:884c9d1a1a84 added z
+  @  22:daf1de08f3b0 added z
   |   () [default] draft
   ~
 
@@ -629,32 +629,32 @@
   $ hg add y
   $ hg amend
 
-  $ hg up 884c9d1a1a84 --hidden
+  $ hg up daf1de08f3b0 --hidden
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  updated to hidden changeset 884c9d1a1a84
-  (hidden revision '884c9d1a1a84' was rewritten as: 3e22a949fe7d)
-  working directory parent is obsolete! (884c9d1a1a84)
-  (use 'hg evolve' to update to its successor: 3e22a949fe7d)
-  $ hg rebase -r . -d bbaca013758a --config experimental.evolution.allowdivergence=True
-  rebasing 21:884c9d1a1a84 "added z"
+  updated to hidden changeset daf1de08f3b0
+  (hidden revision 'daf1de08f3b0' was rewritten as: 3f7a1f693080)
+  working directory parent is obsolete! (daf1de08f3b0)
+  (use 'hg evolve' to update to its successor: 3f7a1f693080)
+  $ hg rebase -r . -d 7bbcf24ddecf --config experimental.evolution.allowdivergence=True
+  rebasing 22:daf1de08f3b0 "added z"
   2 new content-divergent changesets
   $ echo bar > z
   $ hg amend
 
   $ hg glog
-  @  24:d2eca78cc588 added z
+  @  25:53242575ffa9 added z
   |   () [bar] draft
-  | *  22:3e22a949fe7d added z
+  | *  23:3f7a1f693080 added z
   | |   () [default] draft
-  o |  20:bbaca013758a added y
+  o |  21:7bbcf24ddecf added y
   | |   () [bar] draft
-  o |  14:be41fdcd0ee1 added foo to x
+  o |  15:b006cf317e0e added foo to x
   | |   () [bar] draft
-  o |  9:b6b20b8eefdc added d
+  o |  10:4ae4427ee9f8 added d
   | |   () [default] draft
-  o |  8:7c46f743e62f added c
+  o |  9:917281f93fcb added c
   |/    () [default] draft
-  o  5:7ed0642d644b added b
+  o  8:171614c9a791 added b
   |   () [default] draft
   o  1:c7586e2a9264 added a
   |   () [default] draft
@@ -662,26 +662,26 @@
       () [default] draft
 
   $ hg evolve --content-divergent
-  merge:[24] added z
-  with: [22] added z
-  base: [21] added z
-  rebasing "other" content-divergent changeset 3e22a949fe7d on bbaca013758a
+  merge:[25] added z
+  with: [23] added z
+  base: [22] added z
+  rebasing "other" content-divergent changeset 3f7a1f693080 on 7bbcf24ddecf
   merging y
   warning: conflicts while merging y! (edit, then use 'hg resolve --mark')
   abort: unresolved merge conflicts (see hg help resolve)
   [255]
 
   $ hg diff
-  diff -r bbaca013758a y
+  diff -r 7bbcf24ddecf 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: bbaca013758a bar - test: added y
+  +<<<<<<< destination: 7bbcf24ddecf bar - test: added y
    watbar
   +=======
   +foo
-  +>>>>>>> evolving:    3e22a949fe7d - test: added z
-  diff -r bbaca013758a z
+  +>>>>>>> evolving:    3f7a1f693080 - test: added z
+  diff -r 7bbcf24ddecf 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 @@
@@ -693,20 +693,20 @@
   continue: hg evolve --continue
 
   $ hg evolve --continue
-  working directory is now at a15eb4e32166
+  working directory is now at 10c9f94f1e99
 
   $ hg glog
-  @  25:a15eb4e32166 added z
+  @  26:10c9f94f1e99 added z
   |   () [default] draft
-  o  20:bbaca013758a added y
+  o  21:7bbcf24ddecf added y
   |   () [bar] draft
-  o  14:be41fdcd0ee1 added foo to x
+  o  15:b006cf317e0e added foo to x
   |   () [bar] draft
-  o  9:b6b20b8eefdc added d
+  o  10:4ae4427ee9f8 added d
   |   () [default] draft
-  o  8:7c46f743e62f added c
+  o  9:917281f93fcb added c
   |   () [default] draft
-  o  5:7ed0642d644b added b
+  o  8:171614c9a791 added b
   |   () [default] draft
   o  1:c7586e2a9264 added a
   |   () [default] draft
@@ -719,17 +719,17 @@
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID a15eb4e32166b0652fdec4c1dd30c9d668323bac
-  # Parent  bbaca013758a55364955939e2d2e4536cb8d05cf
+  # Node ID 10c9f94f1e9902d905b22019d711d31f3642f589
+  # Parent  7bbcf24ddecfe97d7c2ac6fa8c07c155c8fda47b
   added z
   
-  diff -r bbaca013758a -r a15eb4e32166 y
+  diff -r 7bbcf24ddecf -r 10c9f94f1e99 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 bbaca013758a -r a15eb4e32166 z
+  diff -r 7bbcf24ddecf -r 10c9f94f1e99 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 @@
@@ -910,10 +910,10 @@
   | this command again.
   | - either: hg rebase --dest 'p1(c72d2885eb51)' -r 513e3267034e
   | - or:     hg rebase --dest 'p1(513e3267034e)' -r c72d2885eb51
-  working directory is now at df46e196f3c4
+  working directory is now at b9f381e183a3
 
   $ hg glog
-  @  13:df46e196f3c4 watbar to a
+  @  13:b9f381e183a3 watbar to a
   |   () [default] draft
   | *  12:513e3267034e added d
   | |   () [default] draft
--- a/tests/test-sharing.t	Tue Jun 12 23:20:54 2018 +0530
+++ b/tests/test-sharing.t	Wed Jun 13 17:15:10 2018 +0530
@@ -518,12 +518,12 @@
   base: [4] fix bug 24 (v1)
   merging "other" content-divergent changeset 'e3f99ce9d9cd'
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 5ad6037c046c
+  working directory is now at 711ede2d7a26
   $ hg log -q -r 'contentdivergent()'
 
 Figure SG10: Bob's repository after fixing divergence.
   $ hg --hidden shortlog -G -r 3::
-  @  7:5ad6037c046c  draft  fix bug 24 (v2 by bob)
+  @  7:711ede2d7a26  draft  fix bug 24 (v2 by bob)
   |
   | x  6:e3f99ce9d9cd  draft  fix bug 24 (v2 by alice)
   |/
@@ -534,7 +534,7 @@
   o  3:a06ec1bf97bd  public  fix bug 15 (v2)
   |
   ~
-  $ hg --hidden shortlog -r 'precursors(5ad6037c046c)'
+  $ hg --hidden shortlog -r 'precursors(711ede2d7a26)'
   5:a360947f6faf  draft  fix bug 24 (v2 by bob)
   6:e3f99ce9d9cd  draft  fix bug 24 (v2 by alice)
   $ cat file1
--- a/tests/test-stabilize-result.t	Tue Jun 12 23:20:54 2018 +0530
+++ b/tests/test-stabilize-result.t	Wed Jun 13 17:15:10 2018 +0530
@@ -292,16 +292,14 @@
   resolving manifests
   merging a
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
-  amending changeset eacc9c8240fe
   committing files:
   a
   committing manifest
   committing changelog
-  committed changeset 15:f344982e63c4
-  working directory is now at f344982e63c4
+  working directory is now at 4d6ed26797bc
   $ hg st
   $ glog
-  @  15:f344982e63c4@default(draft) bk:[] More addition
+  @  15:4d6ed26797bc@default(draft) bk:[] More addition
   |
   | o  11:8fc63fe1f297@default(draft) bk:[] phase-divergent update to 1cf0aacfd363:
   | |
@@ -314,7 +312,7 @@
   o  0:07f494440405@default(public) bk:[] adda
   
   $ hg summary
-  parent: 15:f344982e63c4 tip
+  parent: 15:4d6ed26797bc tip
    More addition
   branch: default
   commit: (clean)
@@ -325,11 +323,11 @@
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID f344982e63c462b1e44c0371c804685389e673a9
+  # Node ID 4d6ed26797bc392c0099e48402a5134e669f1a60
   # Parent  7bc2f5967f5e4ed277f60a89b7b04cc5d6407ced
   More addition
   
-  diff -r 7bc2f5967f5e -r f344982e63c4 a
+  diff -r 7bc2f5967f5e -r 4d6ed26797bc a
   --- a/a	Thu Jan 01 00:00:00 1970 +0000
   +++ b/a	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +1,9 @@
@@ -349,9 +347,9 @@
   $ hg up --hidden 3932c176bbaa
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   updated to hidden changeset 3932c176bbaa
-  (hidden revision '3932c176bbaa' was rewritten as: f344982e63c4)
+  (hidden revision '3932c176bbaa' was rewritten as: 4d6ed26797bc)
   working directory parent is obsolete! (3932c176bbaa)
-  (use 'hg evolve' to update to its successor: f344982e63c4)
+  (use 'hg evolve' to update to its successor: 4d6ed26797bc)
   $ echo 'gotta break' >> a
   $ hg amend
   2 new content-divergent changesets
@@ -364,7 +362,7 @@
   $ glog
   @  17:0b336205a5d0@default(draft) bk:[] More addition (2)
   |
-  | *  15:f344982e63c4@default(draft) bk:[] More addition
+  | *  15:4d6ed26797bc@default(draft) bk:[] More addition
   |/
   | o  11:8fc63fe1f297@default(draft) bk:[] phase-divergent update to 1cf0aacfd363:
   | |
@@ -379,8 +377,8 @@
 
   $ hg evolve -qn --content-divergent
   hg update -c 0b336205a5d0 &&
-  hg merge f344982e63c4 &&
-  hg commit -m "auto merge resolving conflict between 0b336205a5d0 and f344982e63c4"&&
+  hg merge 4d6ed26797bc &&
+  hg commit -m "auto merge resolving conflict between 0b336205a5d0 and 4d6ed26797bc"&&
   hg up -C 3932c176bbaa &&
   hg revert --all --rev tip &&
   hg commit -m "`hg log -r 0b336205a5d0 --template={desc}`";
@@ -388,7 +386,7 @@
   merge:[17] More addition (2)
   with: [15] More addition
   base: [12] More addition
-  merging "other" content-divergent changeset 'f344982e63c4'
+  merging "other" content-divergent changeset '4d6ed26797bc'
   merging a
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
@@ -411,9 +409,9 @@
   (no more unresolved files)
   continue: hg evolve --continue
   $ hg evolve --continue
-  working directory is now at e015aa78acee
+  working directory is now at e8746835a2a1
   $ glog
-  @  18:e015aa78acee@default(draft) bk:[] More addition (2)
+  @  18:e8746835a2a1@default(draft) bk:[] More addition (2)
   |
   | o  11:8fc63fe1f297@default(draft) bk:[] phase-divergent update to 1cf0aacfd363:
   | |
@@ -430,11 +428,11 @@
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID e015aa78acee692d26215fafdb7f70974682739c
+  # Node ID e8746835a2a13122bc8c0ed84fe4ee35649af25d
   # Parent  7bc2f5967f5e4ed277f60a89b7b04cc5d6407ced
   More addition (2)
   
-  diff -r 7bc2f5967f5e -r e015aa78acee a
+  diff -r 7bc2f5967f5e -r e8746835a2a1 a
   --- a/a	Thu Jan 01 00:00:00 1970 +0000
   +++ b/a	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +1,9 @@