[PATCH 24 of 25 RFC] shelve: use the internal phase when possible

Boris Feld boris.feld at octobus.net
Thu Jun 7 10:11:23 EDT 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1527588738 -7200
#      Tue May 29 12:12:18 2018 +0200
# Node ID bdd0e592a83f124210517cd776f900a746946466
# Parent  97a1e0703c90bf392e759f3d3e463b2f79110a7a
# EXP-Topic internal-phase
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r bdd0e592a83f
shelve: use the internal phase when possible

If the repository support it, use the internal phase for all changesets
created by shelve.

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -139,11 +139,14 @@ class shelvedfile(object):
     def applybundle(self):
         fp = self.opener()
         try:
+            targetphase = phases.internal
+            if not phases.supportinternal(self.repo):
+                targetphase = phases.secret
             gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs)
             bundle2.applybundle(self.repo, gen, self.repo.currenttransaction(),
                                 source='unshelve',
                                 url='bundle:' + self.vfs.join(self.fname),
-                                targetphase=phases.secret)
+                                targetphase=targetphase)
         finally:
             fp.close()
 
@@ -376,7 +379,11 @@ def getcommitfunc(extra, interactive, ed
         hasmq = util.safehasattr(repo, 'mq')
         if hasmq:
             saved, repo.mq.checkapplied = repo.mq.checkapplied, False
-        overrides = {('phases', 'new-commit'): phases.secret}
+
+        targetphase = phases.internal
+        if not phases.supportinternal(repo):
+            targetphase = phases.secret
+        overrides = {('phases', 'new-commit'): targetphase}
         try:
             editor_ = False
             if editor:
@@ -693,7 +700,10 @@ def unshelvecontinue(ui, repo, state, op
             repo.setparents(state.pendingctx.node(), nodemod.nullid)
             repo.dirstate.write(repo.currenttransaction())
 
-        overrides = {('phases', 'new-commit'): phases.secret}
+        targetphase = phases.internal
+        if not phases.supportinternal(repo):
+            targetphase = phases.secret
+        overrides = {('phases', 'new-commit'): targetphase}
         with repo.ui.configoverride(overrides, 'unshelve'):
             with repo.dirstate.parentchange():
                 repo.setparents(state.parents[0], nodemod.nullid)
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1,3 +1,5 @@
+#testcases stripbased phasebased
+
   $ cat <<EOF >> $HGRCPATH
   > [extensions]
   > mq =
@@ -9,6 +11,15 @@
   > maxbackups = 2
   > EOF
 
+#if phasebased
+
+  $ cat <<EOF >> $HGRCPATH
+  > [format]
+  > internal-phase = yes
+  > EOF
+
+#endif
+
   $ hg init repo
   $ cd repo
   $ mkdir a b


More information about the Mercurial-devel mailing list