changeset 33813:5904511fc9f8

exchange: remove need for "locked" variable The transactionmanager() constructor just assigned a few variables and cannot fail, so it's safe to move it inside the earlier try/except. Differential Revision: https://phab.mercurial-scm.org/D391
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 14 Aug 2017 16:26:36 -0700
parents 20d663a104fb
children bbbbd3c30bfc
files mercurial/exchange.py
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Mon Aug 14 16:14:14 2017 -0700
+++ b/mercurial/exchange.py	Mon Aug 14 16:26:36 2017 -0700
@@ -440,7 +440,6 @@
 
     # get lock as we might write phase data
     wlock = lock = None
-    locked = False
     try:
         # bundle2 push may receive a reply bundle touching bookmarks or other
         # things requiring the wlock. Take it now to ensure proper ordering.
@@ -448,7 +447,9 @@
         if (not _forcebundle1(pushop)) and maypushback:
             wlock = pushop.repo.wlock()
         lock = pushop.repo.lock()
-        locked = True
+        pushop.trmanager = transactionmanager(pushop.repo,
+                                              'push-response',
+                                              pushop.remote.url())
     except IOError as err:
         if err.errno != errno.EACCES:
             raise
@@ -457,11 +458,8 @@
         # synchronisation.
         msg = 'cannot lock source repository: %s\n' % err
         pushop.ui.debug(msg)
+
     try:
-        if locked:
-            pushop.trmanager = transactionmanager(pushop.repo,
-                                                  'push-response',
-                                                  pushop.remote.url())
         pushop.repo.checkpush(pushop)
         _pushdiscovery(pushop)
         if not _forcebundle1(pushop):