Patchwork [09,of,10] shelve: use the internal phase when possible

login
register
mail settings
Submitter Boris Feld
Date Aug. 29, 2018, 4:30 p.m.
Message ID <ccb9572516145a1b6f11.1535560257@localhost.localdomain>
Download mbox | patch
Permalink /patch/34153/
State Accepted
Headers show

Comments

Boris Feld - Aug. 29, 2018, 4:30 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1527588738 -7200
#      Tue May 29 12:12:18 2018 +0200
# Node ID ccb9572516145a1b6f11a8d199c4a7da4774898b
# Parent  5726fcca7837180c0f25ed345236625797725aa5
# EXP-Topic internal-phase.shelve
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ccb957251614
shelve: use the internal phase when possible

If the repository support it, use the internal phase for all changesets
created by shelve.
Augie Fackler - Aug. 30, 2018, 9:02 p.m.
> On Aug 29, 2018, at 12:30 PM, Boris Feld <boris.feld@octobus.net> wrote:
> 
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1527588738 -7200
> #      Tue May 29 12:12:18 2018 +0200
> # Node ID ccb9572516145a1b6f11a8d199c4a7da4774898b
> # Parent  5726fcca7837180c0f25ed345236625797725aa5
> # EXP-Topic internal-phase.shelve
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ccb957251614
> shelve: use the internal phase when possible

The next patch got me to thinking: shouldn’t we only enable this if rebase will use obsmarkers instead of strip?

Patches 4-8 are queued, with a few typo fixes in flight.
Boris Feld - Sept. 7, 2018, 6:12 p.m.
On 30/08/2018 17:02, Augie Fackler wrote:
>
>> On Aug 29, 2018, at 12:30 PM, Boris Feld <boris.feld@octobus.net> wrote:
>>
>> # HG changeset patch
>> # User Boris Feld <boris.feld@octobus.net>
>> # Date 1527588738 -7200
>> #      Tue May 29 12:12:18 2018 +0200
>> # Node ID ccb9572516145a1b6f11a8d199c4a7da4774898b
>> # Parent  5726fcca7837180c0f25ed345236625797725aa5
>> # EXP-Topic internal-phase.shelve
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ccb957251614
>> shelve: use the internal phase when possible
> The next patch got me to thinking: shouldn’t we only enable this if rebase will use obsmarkers instead of strip?
Since we have the bundle and the patch file as backup, we can safely 
strip the internal changeset when doing the rebase's cleanup. It means 
teaching `scmutil.cleanupnodes` code to ignore them.
>
> Patches 4-8 are queued, with a few typo fixes in flight.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler - Sept. 10, 2018, 7:52 p.m.
> On Sep 7, 2018, at 14:12, Boris FELD <boris.feld@octobus.net> wrote:
> 
> On 30/08/2018 17:02, Augie Fackler wrote:
>> 
>>> On Aug 29, 2018, at 12:30 PM, Boris Feld <boris.feld@octobus.net> wrote:
>>> 
>>> # HG changeset patch
>>> # User Boris Feld <boris.feld@octobus.net>
>>> # Date 1527588738 -7200
>>> #      Tue May 29 12:12:18 2018 +0200
>>> # Node ID ccb9572516145a1b6f11a8d199c4a7da4774898b
>>> # Parent  5726fcca7837180c0f25ed345236625797725aa5
>>> # EXP-Topic internal-phase.shelve
>>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ccb957251614
>>> shelve: use the internal phase when possible
>> The next patch got me to thinking: shouldn’t we only enable this if rebase will use obsmarkers instead of strip?
> Since we have the bundle and the patch file as backup, we can safely strip the internal changeset when doing the rebase's cleanup. It means teaching `scmutil.cleanupnodes` code to ignore them.

hm, okay. In any event, queued 9 and 10. Thanks.

>> 
>> Patches 4-8 are queued, with a few typo fixes in flight.
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -140,11 +140,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()
 
@@ -380,7 +383,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:
@@ -702,7 +709,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