From patchwork Tue Feb 11 00:01:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [08, of, 11, (19, more, to, go)] push: move local phase move in a normal function From: Pierre-Yves David X-Patchwork-Id: 3554 Message-Id: To: mercurial-devel@selenic.com Cc: pierre-yves.david@ens-lyon.org Date: Mon, 10 Feb 2014 16:01:36 -0800 # HG changeset patch # User Pierre-Yves David # 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`. 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 to 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 to 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