evolvestate: store info about relocation while resolving content-divergence
authorPulkit Goyal <7895pulkit@gmail.com>
Thu, 07 Jun 2018 18:18:10 +0530
changeset 3809 f06ff8fee2f6
parent 3808 e6c0f45d51ed
child 3810 04fe01b0c0d0
evolvestate: store info about relocation while resolving content-divergence While resolving content-divergence when they are on different parents, we relocate one of the node to parent of another one and this can lead to conflicts sometimes. So we need to store information about that state in evolvestate so that we can use that when user does `hg evolve --continue` or `--stop` or `--abort`. Now that we make sure, we store the new other node in evolvestate, we fix the behavior of handling the relocated commit and merge the right changesets.
hgext3rd/evolve/evolvecmd.py
tests/test-evolve-content-divergence.t
--- a/hgext3rd/evolve/evolvecmd.py	Thu Jun 07 18:13:54 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Thu Jun 07 18:18:10 2018 +0530
@@ -343,6 +343,14 @@
     repo = repo.unfiltered()
     divergent = repo[divergent.rev()]
     evolvestate['divergent'] = divergent.node()
+    # sometimes we will relocate a node in case of different parents and we can
+    # encounter conflicts after relocation is done while solving
+    # content-divergence and if the user calls `hg evolve --stop`, we need to
+    # strip that relocated commit. However if `--all` is passed, we need to
+    # reset this value for each content-divergence resolution which we are doing
+    # below.
+    evolvestate['relocated'] = None
+    evolvestate['relocating'] = False
     base, others = divergentdata(divergent)
 
     # we don't handle split in content-divergence yet
@@ -443,11 +451,20 @@
 
     # relocate the other divergent if required
     if relocatereq:
+        evolvestate['current'] = other.node()
+        # relocating will help us understand during the time of conflicts that
+        # whether conflicts occur at reloacting or they occured at merging
+        # content divergent changesets
+        evolvestate['relocating'] = True
         ui.status(_('rebasing "other" content-divergent changeset %s on'
                     ' %s\n' % (other, divergent.p1())))
         newother = relocate(repo, other, divergent.p1(), evolvestate,
                             keepbranch=True)
         other = repo[newother]
+        evolvestate['relocating'] = False
+        evolvestate['relocated'] = other.node()
+        evolvestate['temprevs'].append(other.node())
+        evolvestate['other-divergent'] = other.node()
 
     _mergecontentdivergents(repo, progresscb, divergent, other, base,
                             evolvestate)
--- a/tests/test-evolve-content-divergence.t	Thu Jun 07 18:13:54 2018 +0530
+++ b/tests/test-evolve-content-divergence.t	Thu Jun 07 18:18:10 2018 +0530
@@ -545,8 +545,6 @@
   $ hg glog
   @  20:bbaca013758a added y
   |   () [bar] draft
-  | *  19:6d515d1ffc69 added y
-  |/    () [default] draft
   o  14:be41fdcd0ee1 added foo to x
   |   () [bar] draft
   o  9:b6b20b8eefdc added d
@@ -561,18 +559,18 @@
       () [default] draft
 
   $ hg obslog -r . --all
-  *  6d515d1ffc69 (19) added y
-  |
-  | @  bbaca013758a (20) added y
-  |/|
-  x |  29e08829c51f (16) added y
-  | |    rewritten(parent) as 6d515d1ffc69 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
-  | |    rewritten(branch, parent, content) as bbaca013758a using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
-  | |
-  | x  4065e1d314c3 (18) added y
+  @    bbaca013758a (20) added y
+  |\
+  x |  4065e1d314c3 (18) added y
   | |    rewritten(content) as bbaca013758a using amend by test (Thu Jan 01 00:00:00 1970 +0000)
   | |
-  | x  f1d75198aac4 (17) added y
+  | x  6d515d1ffc69 (19) added y
+  | |    rewritten(branch, content) as bbaca013758a 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 |  f1d75198aac4 (17) added y
   |/     rewritten(content) as 4065e1d314c3 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
   |
   x  9c30046901ab (15) added y