evolve: strip the relocation commit on `hg evolve --stop`
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 11 Jun 2018 00:47:28 +0530
changeset 3827 82c72eb37f85
parent 3826 8e8bd5bb2f90
child 3828 c58ebf5d2f57
evolve: strip the relocation commit on `hg evolve --stop` While resolving content-divergence on multiple parents, we relocate one of the commit on the parent of another one and then merge the divergent changesets. Merging can leads to conflicts, and if user does `hg evolve --stop`, we need to strip that relocated changeset too! This patch does that. Test changes demonstrates the fix.
hgext3rd/evolve/evolvecmd.py
tests/test-evolve-stop-contentdiv.t
--- a/hgext3rd/evolve/evolvecmd.py	Mon Jun 11 00:43:39 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Mon Jun 11 00:47:28 2018 +0530
@@ -1476,6 +1476,18 @@
     """logic for handling of `hg evolve --stop`"""
     updated = False
     pctx = None
+    if (evolvestate['command'] == 'evolve' and
+        evolvestate['category'] == 'contentdivergent' and
+        evolvestate['relocated']):
+        oldother = evolvestate['old-other']
+        if oldother:
+            with repo.wlock(), repo.lock():
+                repo = repo.unfiltered()
+                hg.updaterepo(repo, oldother, True)
+                strips = [evolvestate['relocated']]
+                repair.strip(ui, repo, strips, False)
+                updated = True
+                pctx = repo[oldother]
     if not updated:
         pctx = repo['.']
         hg.updaterepo(repo, pctx.node(), True)
--- a/tests/test-evolve-stop-contentdiv.t	Mon Jun 11 00:43:39 2018 +0530
+++ b/tests/test-evolve-stop-contentdiv.t	Mon Jun 11 00:47:28 2018 +0530
@@ -134,18 +134,17 @@
 
   $ hg evolve --stop
   stopped the interrupted evolve
-  working directory is now at e49523854bc8
+  working directory is now at 517d4375cb72
 
-XXX: we need to strip the relocated commit
   $ hg glog
-  *  8:606ad96040fc added d
+  @  7:517d4375cb72 added d
   |   () draft
-  | @  5:e49523854bc8 added d
+  | *  5:e49523854bc8 added d
+  | |   () draft
+  | o  3:ca1b80f7960a added c
+  | |   () draft
+  | o  2:b1661037fa25 added b
   |/    () draft
-  o  3:ca1b80f7960a added c
-  |   () draft
-  o  2:b1661037fa25 added b
-  |   () draft
   o  1:c7586e2a9264 added a
   |   () draft
   o  0:8fa14d15e168 added hgignore