diff hgext/uncommit.py @ 38429:32fba6fe893d

scmutil: make cleanupnodes optionally also fix the phase We have had multiple bugs where the phase wasn't correctly carried forward to a rewritten changeset (for example: phabricator, split, evolve, fix). Handling the phase update in cleanupnodes() makes it less likely to happen again, especially once we have made it fix the phase by default (perhaps in the next release cycle). This patch also updates all applicable callers so we get some testing of it. Note that rebase and histedit can't be fixed yet because they call cleanupnodes() only at the end and the phase may have been changed by the user when the rebase/histedit was interrupted (due to merge conflicts). I think we should make them write one commit at a time (as it already does), along with associated obsmarkers, bookmark moves, etc. When that's done, we can switch them over to cleanupnodes(). Differential Revision: https://phab.mercurial-scm.org/D3818
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 19 Jun 2018 11:07:40 -0700
parents 435b8b05affd
children 3bd22c4d3711
line wrap: on
line diff
--- a/hgext/uncommit.py	Tue Jun 19 11:07:23 2018 -0700
+++ b/hgext/uncommit.py	Tue Jun 19 11:07:40 2018 -0700
@@ -91,12 +91,7 @@
                          user=ctx.user(),
                          date=ctx.date(),
                          extra=ctx.extra())
-    # phase handling
-    commitphase = ctx.phase()
-    overrides = {('phases', 'new-commit'): commitphase}
-    with repo.ui.configoverride(overrides, 'uncommit'):
-        newid = repo.commitctx(new)
-    return newid
+    return repo.commitctx(new)
 
 def _fixdirstate(repo, oldctx, newctx, status):
     """ fix the dirstate after switching the working directory from oldctx to
@@ -183,7 +178,7 @@
                 # Fully removed the old commit
                 mapping[old.node()] = ()
 
-            scmutil.cleanupnodes(repo, mapping, 'uncommit')
+            scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True)
 
             with repo.dirstate.parentchange():
                 repo.dirstate.setparents(newid, node.nullid)
@@ -242,12 +237,7 @@
                                 user=predctx.user(),
                                 date=predctx.date(),
                                 extra=extras)
-        # phase handling
-        commitphase = curctx.phase()
-        overrides = {('phases', 'new-commit'): commitphase}
-        with repo.ui.configoverride(overrides, 'uncommit'):
-            newprednode = repo.commitctx(newctx)
-
+        newprednode = repo.commitctx(newctx)
         newpredctx = repo[newprednode]
         dirstate = repo.dirstate
 
@@ -257,4 +247,4 @@
             _fixdirstate(repo, curctx, newpredctx, s)
 
         mapping = {curctx.node(): (newprednode,)}
-        scmutil.cleanupnodes(repo, mapping, 'unamend')
+        scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True)