split: preserve phase of commit that is being split
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 19 Jun 2018 13:49:06 -0700
changeset 38424 4f885770c4a2
parent 38423 32fba6fe893d
child 38426 00368bc0a614
split: preserve phase of commit that is being split With this change, hg split will preserve the phase of the commit that is being split, ignoring the phases.new-commit setting. Previously, we would use whatever phases.new-commit was set to (unless our parent was secret, then we would be secret even if phases.new-commit=draft). Now, splitting a draft commit with phases.new-commit=secret does not cause the new commits to become secret, and splitting a secret commit with phases.new-commit=draft and a draft parent does not cause the new commits to become draft. Test cases and commit message taken from Kyle Lippincott's D2016 (thanks!). Differential Revision: https://phab.mercurial-scm.org/D3819
hgext/split.py
tests/test-split.t
--- a/hgext/split.py	Tue Jun 19 11:07:40 2018 -0700
+++ b/hgext/split.py	Tue Jun 19 13:49:06 2018 -0700
@@ -170,7 +170,7 @@
         raise error.Abort(_('cannot split an empty revision'))
 
     scmutil.cleanupnodes(repo, {ctx.node(): [c.node() for c in committed]},
-                         operation='split')
+                         operation='split', fixphase=True)
 
     return committed[-1]
 
--- a/tests/test-split.t	Tue Jun 19 11:07:40 2018 -0700
+++ b/tests/test-split.t	Tue Jun 19 13:49:06 2018 -0700
@@ -532,3 +532,36 @@
   o  0:426bada5c675 A
   
 #endif
+
+Preserve secret phase in split
+
+  $ cp -R $TESTTMP/clean $TESTTMP/phases1
+  $ cd $TESTTMP/phases1
+  $ hg phase --secret -fr tip
+  $ hg log -T '{short(node)} {phase}\n'
+  1df0d5c5a3ab secret
+  a61bcde8c529 draft
+  $ runsplit tip >/dev/null
+  $ hg log -T '{short(node)} {phase}\n'
+  00eebaf8d2e2 secret
+  a09ad58faae3 secret
+  e704349bd21b secret
+  a61bcde8c529 draft
+
+Do not move things to secret even if phases.new-commit=secret
+
+  $ cp -R $TESTTMP/clean $TESTTMP/phases2
+  $ cd $TESTTMP/phases2
+  $ cat >> .hg/hgrc <<EOF
+  > [phases]
+  > new-commit=secret
+  > EOF
+  $ hg log -T '{short(node)} {phase}\n'
+  1df0d5c5a3ab draft
+  a61bcde8c529 draft
+  $ runsplit tip >/dev/null
+  $ hg log -T '{short(node)} {phase}\n'
+  00eebaf8d2e2 draft
+  a09ad58faae3 draft
+  e704349bd21b draft
+  a61bcde8c529 draft