push: move local lock logic in pushoperation
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 30 Jan 2014 20:00:34 -0800
changeset 20436 2f2e8d1c4856
parent 20435 46ede894d5a4
child 20437 9e54faf37ff8
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.
mercurial/exchange.py
--- a/mercurial/exchange.py	Thu Jan 30 19:55:09 2014 -0800
+++ b/mercurial/exchange.py	Thu Jan 30 20:00:34 2014 -0800
@@ -33,6 +33,8 @@
         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
@@ -66,7 +68,7 @@
     unfi = pushop.repo.unfiltered()
     def localphasemove(nodes, phase=phases.public):
         """move <nodes> to <phase> 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!
@@ -81,7 +83,9 @@
     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.