Mercurial > public > mercurial-scm > hg
diff mercurial/exchange.py @ 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 | f9aa4cb8f2dd |
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