From patchwork Tue Feb 11 00:01:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [06, of, 11, (19, more, to, go)] push: move local lock logic in pushoperation From: Pierre-Yves David X-Patchwork-Id: 3551 Message-Id: <41b273449477a7d28aee.1392076894@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: pierre-yves.david@ens-lyon.org Date: Mon, 10 Feb 2014 16:01:34 -0800 # HG changeset patch # User Pierre-Yves David # Date 1391140834 28800 # Thu Jan 30 20:00:34 2014 -0800 # Node ID 41b273449477a7d28aeeb5b2479fd3eeb64e8cda # Parent 8b97b0a12ed0bdd5c33c56d99ed08342c0a0bc9d push: move local lock logic in pushoperation During push, we try to lock the local repo to move local phase according to what we saw/pushed on the remote repo. Locking the repo may fail, in that case we let the push proceed without local phase movement (printing warning). This mean we have code in phase synchronisation that will check if the local repo is locked or not. we need to move this information in the push object to be able to extract the phase synchronisation in its own function. This is done as a boolean because putting reference to the actual lock outside of the main function sounded a bad idea. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -31,10 +31,12 @@ class pushoperation(object): self.force = force # revs to be pushed (None is "all") self.revs = revs # allow push of new branch self.newbranch = newbranch + # did a local lock get acquired? + self.locallocked = None def push(repo, remote, force=False, revs=None, newbranch=False): '''Push outgoing changesets (limited by revs) from a local repository to remote. Return an integer: - None means nothing to push @@ -64,11 +66,11 @@ def push(repo, remote, force=False, revs if not pushop.remote.canpush(): raise util.Abort(_("destination does not support push")) unfi = pushop.repo.unfiltered() def localphasemove(nodes, phase=phases.public): """move to in the local source repo""" - if locallock is not None: + 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. @@ -79,11 +81,13 @@ def push(repo, remote, force=False, revs '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 except IOError, err: + pushop.locallocked = False if err.errno != errno.EACCES: raise # source repo cannot be locked. # We do not abort the push, but just disable the local phase # synchronisation.