changeset 24754:5dc5cd7abbf5

push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596) If the client allows "pushback", the bundle2 served back by the server may contains parts that will write to the repository. Such parts may require the 'wlock' (eg: bookmark) so we acquire it in advance to make sure it got acquired before the 'lock'.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 15 Apr 2015 10:36:21 -0400
parents 5640efd1b160
children cd89f4e6faf2
files mercurial/exchange.py tests/test-bundle2-pushback.t
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Wed Apr 15 01:16:40 2015 -0400
+++ b/mercurial/exchange.py	Wed Apr 15 10:36:21 2015 -0400
@@ -201,8 +201,13 @@
     if not pushop.remote.canpush():
         raise util.Abort(_("destination does not support push"))
     # get local lock as we might write phase data
-    locallock = None
+    localwlock = locallock = None
     try:
+        # bundle2 push may receive a reply bundle touching bookmarks or other
+        # things requiring the wlock. Take it now to ensure proper ordering.
+        maypushback = pushop.ui.configbool('experimental', 'bundle2.pushback')
+        if _canusebundle2(pushop) and maypushback:
+            localwlock = pushop.repo.wlock()
         locallock = pushop.repo.lock()
         pushop.locallocked = True
     except IOError, err:
@@ -242,6 +247,8 @@
             pushop.trmanager.release()
         if locallock is not None:
             locallock.release()
+        if localwlock is not None:
+            localwlock.release()
 
     return pushop
 
--- a/tests/test-bundle2-pushback.t	Wed Apr 15 01:16:40 2015 -0400
+++ b/tests/test-bundle2-pushback.t	Wed Apr 15 10:36:21 2015 -0400
@@ -91,7 +91,6 @@
   $ hg push
   pushing to ssh://user@dummy/server
   searching for changes
-  "wlock" acquired after "lock" at: */mercurial/bookmarks.py:259 (pushbookmark) (glob)
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes