Patchwork [4,of,6] shelve: do not retract phase boundary by hand

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 6, 2014, 4:27 a.m.
Message ID <ab3ee8efb2e3f8082698.1407299252@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5286/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 6, 2014, 4:27 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1407274665 25200
#      Tue Aug 05 14:37:45 2014 -0700
# Node ID ab3ee8efb2e3f80826985df5d1a8837a4d539a52
# Parent  e55c90663515bf11cce9fdf6459c7d6b6789015e
shelve: do not retract phase boundary by hand.

We rely on the internal mechanism to commit the changeset in the right state.
This similar to what the mq extension is doing.

This is an important change as we plan to move phase movement with the
transaction. Avoiding phase movement from high level code will avoid them the
burden of transaction handling. It is also important to limit the need for
transaction handling as this limit the odds of people messing up. Most common
expected mess up is  to use a different transaction for changesets creation and
phase adjustment.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -175,14 +175,17 @@  def createcmd(ui, repo, pats, opts):
         for flist in repo.status(match=match)[:4]:
             shelvedfiles.extend(flist)
         hasmq = util.safehasattr(repo, 'mq')
         if hasmq:
             saved, repo.mq.checkapplied = repo.mq.checkapplied, False
+        backup = repo.ui.backupconfig('phases', 'new-commit')
         try:
+            repo.ui. setconfig('phases', 'new-commit', phases.secret)
             return repo.commit(message, user, opts.get('date'), match,
                                editor=cmdutil.getcommiteditor(**opts))
         finally:
+            repo.ui.restoreconfig(backup)
             if hasmq:
                 repo.mq.checkapplied = saved
 
     if parent.node() != nullid:
         desc = "changes to '%s'" % parent.description().split('\n', 1)[0]
@@ -232,12 +235,10 @@  def createcmd(ui, repo, pats, opts):
                             "'hg status')\n") % len(stat[3]))
             else:
                 ui.status(_("nothing changed\n"))
             return 1
 
-        phases.retractboundary(repo, phases.secret, [node])
-
         fp = shelvedfile(repo, name, 'files').opener('wb')
         fp.write('\0'.join(shelvedfiles))
 
         bases = list(publicancestors(repo[node]))
         cg = changegroup.changegroupsubset(repo, bases, [node], 'shelve')
@@ -556,14 +557,17 @@  def unshelve(ui, repo, *shelved, **opts)
             def commitfunc(ui, repo, message, match, opts):
                 hasmq = util.safehasattr(repo, 'mq')
                 if hasmq:
                     saved, repo.mq.checkapplied = repo.mq.checkapplied, False
 
+                backup = repo.ui.backupconfig('phases', 'new-commit')
                 try:
+                    repo.ui. setconfig('phases', 'new-commit', phases.secret)
                     return repo.commit(message, 'shelve@localhost',
                                        opts.get('date'), match)
                 finally:
+                    repo.ui.restoreconfig(backup)
                     if hasmq:
                         repo.mq.checkapplied = saved
 
             tempopts = {}
             tempopts['message'] = "pending changes temporary commit"