Patchwork [1,of,2,STABLE,V2] push: factorise phase movement in a simple closure

mail settings
Submitter Pierre-Yves David
Date April 30, 2013, 7:27 p.m.
Message ID <efad78b96b8ec2c85bc7.1367350050@yamac.lan>
Download mbox | patch
Permalink /patch/1516/
State Accepted
Commit 0e4af72cbd7f3e4bfd2d010458467b784dae6ffe
Headers show


Pierre-Yves David - April 30, 2013, 7:27 p.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1367311885 -7200
#      Tue Apr 30 10:51:25 2013 +0200
# Branch stable
# Node ID efad78b96b8ec2c85bc76996ebbcc8e059356796
# Parent  f01a351db79106ba96ac6d527cf69944fd98e665
push: factorise phase movement in a simple closure

Having all phases movement centralised will help to handle special case when the
local repo can not be locked as describe in issue 3684.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -1760,10 +1760,13 @@  class localrepository(object):
         # servers, http servers).
         if not remote.canpush():
             raise util.Abort(_("destination does not support push"))
         unfi = self.unfiltered()
+        def localphasemove(nodes, phase=phases.public):
+            """move <nodes> to <phase> in the local source repo"""
+            phases.advanceboundary(self, phase, nodes)
         # get local lock as we might write phase data
         locallock = self.lock()
             self.checkpush(force, revs)
             lock = None
@@ -1881,21 +1884,21 @@  class localrepository(object):
                     # We drop the possible phase synchronisation done by
                     # courtesy to publish changesets possibly locally draft
                     # on the remote.
                     remotephases = {'publishing': 'True'}
                 if not remotephases: # old server or public only repo
-                    phases.advanceboundary(self, phases.public, cheads)
+                    localphasemove(cheads)
                     # don't push any phase data as there is nothing to push
                     ana = phases.analyzeremotephases(self, cheads, remotephases)
                     pheads, droots = ana
                     ### Apply remote phase on local
                     if remotephases.get('publishing', False):
-                        phases.advanceboundary(self, phases.public, cheads)
+                        localphasemove(cheads)
                     else: # publish = False
-                        phases.advanceboundary(self, phases.public, pheads)
-                        phases.advanceboundary(self, phases.draft, cheads)
+                        localphasemove(pheads)
+                        localphasemove(cheads, phases.draft)
                     ### Apply local phase on remote
                     # Get the list of all revs draft on remote by public here.
                     # XXX Beware that revset break if droots is not strictly
                     # XXX root we may want to ensure it is but it is costly