evolve: return the new node formed only as the replacement
authorPulkit Goyal <7895pulkit@gmail.com>
Thu, 24 May 2018 02:12:14 +0530
changeset 3792 bb7d1616407f
parent 3791 63d6d024dfb2
child 3794 b89108d3eca0
evolve: return the new node formed only as the replacement sometimes, the the other content divergent changeset is obsoleted in favour of the local divergent changeset in which case we should not store that as a replacement because `hg evolve --abort` will strip that changeset. Let's make sure we return the newnode only if formed. The test results shows that we are still not 100% accurate as we need to strip an obsmarker.
hgext3rd/evolve/evolvecmd.py
tests/test-evolve-abort-contentdiv.t
--- a/hgext3rd/evolve/evolvecmd.py	Thu May 24 17:04:20 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Thu May 24 02:12:14 2018 +0530
@@ -484,6 +484,8 @@
             elif index == 2:
                 repo.dirstate.setbranch(othbranch)
 
+        # 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='', logfile='')
         # XXX: we can get rid of this len() call also by creating a new commit
@@ -492,11 +494,12 @@
             # no changes
         else:
             new = repo['.']
+            newnode = new.node()
 
         # creating markers and moving phases post-resolution
         obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
         phases.retractboundary(repo, tr, other.phase(), [new.node()])
-        return (True, new.node())
+        return (True, newnode)
     finally:
         repo.ui.restoreconfig(emtpycommitallowed)
 
--- a/tests/test-evolve-abort-contentdiv.t	Thu May 24 17:04:20 2018 +0530
+++ b/tests/test-evolve-abort-contentdiv.t	Thu May 24 02:12:14 2018 +0530
@@ -165,16 +165,16 @@
   abort: fix conflicts and run 'hg evolve --continue' or use 'hg update -C .' to abort
   [255]
 
-XXX: this went wrong and stripped rev 10 also
   $ hg evolve --abort
-  warning: ignoring unknown working parent 491e10505bae!
   evolve aborted
   working directory is now at 491e10505bae
 
   $ hg glog --hidden
-  @  9:491e10505bae added c
+  @  10:491e10505bae added c
   |   () draft
-  | x  8:7398f702a162 added c
+  | x  9:7398f702a162 added c
+  |/    () draft
+  | o  8:2ba73e31f264 added c
   |/    () draft
   | *  7:f0f1694f123e added d
   | |   () draft
@@ -192,3 +192,18 @@
   |   () draft
   o  0:8fa14d15e168 added hgignore
       () draft
+
+XXX: we need to strip off the obsmarker created 10 -> 8
+  $ hg obslog -r . --all
+  o    2ba73e31f264 (8) added c
+  |\
+  @ |  491e10505bae (10) added c
+  | |    rewritten as 2ba73e31f264 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |
+  x |  7398f702a162 (9) added c
+  |/     rewritten(content) as 491e10505bae using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+  |
+  x  ca1b80f7960a (3) added c
+       rewritten(content) as 2ba73e31f264 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+       rewritten(content) as 7398f702a162 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+