evolve: use phases.new-commit config to retain phase information (issue5720)
authorPulkit Goyal <7895pulkit@gmail.com>
Tue, 09 Jan 2018 15:39:47 +0530
changeset 3388 be41e4740a25
parent 3387 b3be4797d3c6
child 3389 eacf6149b678
evolve: use phases.new-commit config to retain phase information (issue5720) Since the previous patches replaced the use of graftstate with evolvestate and we don't graft anymore on evolve --continue, we have now the capability to fix underlying bugs. This patch makes sure we use the phases.new-commit config to make a new commit of the same phase as that of the predecessor. Tests added in the previous patch shows the bug being fixed.
CHANGELOG
hgext3rd/evolve/__init__.py
tests/test-evolve-phase.t
tests/test-issue-5720.t
--- a/CHANGELOG	Tue Jan 09 15:33:57 2018 +0530
+++ b/CHANGELOG	Tue Jan 09 15:39:47 2018 +0530
@@ -15,6 +15,8 @@
     dropped, please update both clients and servers. The new approach is still
     hidden behind and experimental flag for now.
 
+  * preserve phase information during interrupted `hg evolve` (issue5720)
+
 topic (0.7.1)
 
 7.1.1 - in progress
--- a/hgext3rd/evolve/__init__.py	Tue Jan 09 15:33:57 2018 +0530
+++ b/hgext3rd/evolve/__init__.py	Tue Jan 09 15:39:47 2018 +0530
@@ -1598,8 +1598,13 @@
             message = ctx.description()
             ui.status(_('evolving %d:%s "%s"\n') % (ctx.rev(), ctx,
                                                     message.split('\n', 1)[0]))
-            node = repo.commit(text=message, user=user,
-                               date=date, extra=extra)
+            targetphase = max(ctx.phase(), phases.draft)
+            overrides = {('phases', 'new-commit'): targetphase}
+
+            with repo.ui.configoverride(overrides, 'evolve-continue'):
+                node = repo.commit(text=message, user=user,
+                                   date=date, extra=extra)
+
             obsolete.createmarkers(repo, [(ctx, (repo[node],))])
             _evolvestatedelete(repo)
             return
--- a/tests/test-evolve-phase.t	Tue Jan 09 15:33:57 2018 +0530
+++ b/tests/test-evolve-phase.t	Tue Jan 09 15:39:47 2018 +0530
@@ -107,9 +107,8 @@
   $ hg evolve -c
   evolving 2:13833940840c "c"
 
-XXX: Here 4 should be having secret phase just as same as 2
   $ hg glog
-  @  4 - 3d2080c198e5 c (draft)
+  @  4 - 3d2080c198e5 c (secret)
   |
   o  3 - 87495ea7c9ec b (draft)
   |
--- a/tests/test-issue-5720.t	Tue Jan 09 15:33:57 2018 +0530
+++ b/tests/test-issue-5720.t	Tue Jan 09 15:39:47 2018 +0530
@@ -77,11 +77,11 @@
 
 Tip should stay in secret phase
   $ hg log -G -T "{rev}: {phase}"
-  @  4: draft
+  @  4: secret
   |
   o  3: draft
   |
   o  0: draft
   
   $ hg log -r . -T '{phase}\n'
-  draft
+  secret