# HG changeset patch # User Pierre-Yves David # Date 2015-04-15 14:36:21 # Node ID 5dc5cd7abbf5ed0d5ab72a0891ccaa2127e502b1 # Parent 5640efd1b1608d496894dedf9ee307ebce3a6d5c 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'. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -201,8 +201,13 @@ def push(repo, remote, force=False, revs 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 @@ def push(repo, remote, force=False, revs pushop.trmanager.release() if locallock is not None: locallock.release() + if localwlock is not None: + localwlock.release() return pushop diff --git a/tests/test-bundle2-pushback.t b/tests/test-bundle2-pushback.t --- a/tests/test-bundle2-pushback.t +++ b/tests/test-bundle2-pushback.t @@ -91,7 +91,6 @@ With config $ 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