Patchwork [08,of,11,(19,more,to,go)] push: move local phase move in a normal function

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 11, 2014, 12:01 a.m.
Message ID <f07aad217fedbb12406b.1392076896@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3554/
State Accepted
Commit 2b5ab0d1132736d9669a66d19e5d210d6d16fd01
Headers show

Comments

Pierre-Yves David - Feb. 11, 2014, 12:01 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1391141459 28800
#      Thu Jan 30 20:10:59 2014 -0800
# Node ID f07aad217fedbb12406be847e6d4e6bf18c8c878
# Parent  c4a1b8a92543a517520857c14568db1c7f4f077d
push: move local phase move in a normal function

We now have the modularity for simpler approach `localphasemove`.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -64,23 +64,10 @@  def push(repo, remote, force=False, revs
     # servers, http servers).
 
     if not pushop.remote.canpush():
         raise util.Abort(_("destination does not support push"))
     unfi = pushop.repo.unfiltered()
-    def localphasemove(pushop, nodes, phase=phases.public):
-        """move <nodes> to <phase> in the local source repo"""
-        if pushop.locallocked:
-            phases.advanceboundary(pushop.repo, phase, nodes)
-        else:
-            # repo is not locked, do not change any phases!
-            # Informs the user that phases should have been moved when
-            # applicable.
-            actualmoves = [n for n in nodes if phase < pushop.repo[n].phase()]
-            phasestr = phases.phasenames[phase]
-            if actualmoves:
-                pushop.ui.status(_('cannot lock source repo, skipping '
-                                   'local %s phase update\n') % phasestr)
     # get local lock as we might write phase data
     locallock = None
     try:
         locallock = pushop.repo.lock()
         pushop.locallocked = True
@@ -221,22 +208,22 @@  def push(repo, remote, force=False, revs
                 # 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 rer
-                localphasemove(pushop, cheads)
+                _localphasemove(pushop, cheads)
                 # don't push any phase data as there is nothing to push
             else:
                 ana = phases.analyzeremotephases(pushop.repo, cheads,
                                                  remotephases)
                 pheads, droots = ana
                 ### Apply remote phase on local
                 if remotephases.get('publishing', False):
-                    localphasemove(pushop, cheads)
+                    _localphasemove(pushop, cheads)
                 else: # publish = False
-                    localphasemove(pushop, pheads)
-                    localphasemove(pushop, cheads, phases.draft)
+                    _localphasemove(pushop, pheads)
+                    _localphasemove(pushop, 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
@@ -259,10 +246,24 @@  def push(repo, remote, force=False, revs
             locallock.release()
 
     _pushbookmark(pushop)
     return ret
 
+def _localphasemove(pushop, nodes, phase=phases.public):
+    """move <nodes> to <phase> in the local source repo"""
+    if pushop.locallocked:
+        phases.advanceboundary(pushop.repo, phase, nodes)
+    else:
+        # repo is not locked, do not change any phases!
+        # Informs the user that phases should have been moved when
+        # applicable.
+        actualmoves = [n for n in nodes if phase < pushop.repo[n].phase()]
+        phasestr = phases.phasenames[phase]
+        if actualmoves:
+            pushop.ui.status(_('cannot lock source repo, skipping '
+                               'local %s phase update\n') % phasestr)
+
 def _pushobsolete(pushop):
     """utility function to push obsolete markers to a remote"""
     pushop.ui.debug('try to push obsolete markers to remote\n')
     repo = pushop.repo
     remote = pushop.remote