mercurial/localrepo.py
branchstable
changeset 15952 ec8a9e06cf05
parent 15933 b8696a6676be
child 15956 5653f2d166ea
--- a/mercurial/localrepo.py	Fri Jan 20 00:27:11 2012 +0100
+++ b/mercurial/localrepo.py	Fri Jan 20 18:45:29 2012 +0100
@@ -1597,14 +1597,14 @@
         # unbundle assumes local user cannot lock remote repo (new ssh
         # servers, http servers).
 
-        self.checkpush(force, revs)
-        lock = None
-        unbundle = remote.capable('unbundle')
-        if not unbundle:
-            lock = remote.lock()
+        # get local lock as we might write phase data
+        locallock = self.lock()
         try:
-            # get local lock as we might write phase data
-            locallock = self.lock()
+            self.checkpush(force, revs)
+            lock = None
+            unbundle = remote.capable('unbundle')
+            if not unbundle:
+                lock = remote.lock()
             try:
                 # discovery
                 fci = discovery.findcommonincoming
@@ -1687,10 +1687,10 @@
                             self.ui.warn(_('updating %s to public failed!\n')
                                             % newremotehead)
             finally:
-                locallock.release()
+                if lock is not None:
+                    lock.release()
         finally:
-            if lock is not None:
-                lock.release()
+            locallock.release()
 
         self.ui.debug("checking for updated bookmarks\n")
         rb = remote.listkeys('bookmarks')