changeset 20438:2b5ab0d11327

push: move local phase move in a normal function We now have the modularity for simpler approach `localphasemove`.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 30 Jan 2014 20:10:59 -0800
parents 9e54faf37ff8
children 0d3ccf285ff2
files mercurial/exchange.py
diffstat 1 files changed, 18 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Thu Jan 30 20:09:21 2014 -0800
+++ b/mercurial/exchange.py	Thu Jan 30 20:10:59 2014 -0800
@@ -66,19 +66,6 @@
     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:
@@ -223,7 +210,7 @@
                 # 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,
@@ -231,10 +218,10 @@
                 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.
@@ -261,6 +248,20 @@
     _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')