# HG changeset patch # User Pierre-Yves David # Date 1429075000 14400 # Node ID 5640efd1b1608d496894dedf9ee307ebce3a6d5c # Parent dc4daf028f9c2173f51a9afde8cf53d1354f943e unbundle: acquire 'wlock' when processing bundle2 (BC) (issue4596) A bundle2 may contain bookmark updates (or other extension content) that requires the 'wlock' to be written. As 'wlock' must be acquired before 'lock', we must stay on the side of caution and use both in all case to ensure their ordering. diff -r dc4daf028f9c -r 5640efd1b160 mercurial/exchange.py --- a/mercurial/exchange.py Sun Apr 12 09:46:03 2015 -0400 +++ b/mercurial/exchange.py Wed Apr 15 01:16:40 2015 -0400 @@ -10,6 +10,7 @@ import errno, urllib import util, scmutil, changegroup, base85, error import discovery, phases, obsolete, bookmarks as bookmod, bundle2, pushkey +import lock as lockmod def readbundle(ui, fh, fname, vfs=None): header = changegroup.readexactly(fh, 4) @@ -1275,13 +1276,14 @@ If the push was raced as PushRaced exception is raised.""" r = 0 # need a transaction when processing a bundle2 stream - tr = None - lock = repo.lock() + wlock = lock = tr = None try: check_heads(repo, heads, 'uploading changes') # push can proceed if util.safehasattr(cg, 'params'): try: + wlock = repo.wlock() + lock = repo.lock() tr = repo.transaction(source) tr.hookargs['source'] = source tr.hookargs['url'] = url @@ -1292,9 +1294,8 @@ exc.duringunbundle2 = True raise else: + lock = repo.lock() r = changegroup.addchangegroup(repo, cg, source, url) finally: - if tr is not None: - tr.release() - lock.release() + lockmod.release(tr, lock, wlock) return r diff -r dc4daf028f9c -r 5640efd1b160 tests/test-bundle2-exchange.t --- a/tests/test-bundle2-exchange.t Sun Apr 12 09:46:03 2015 -0400 +++ b/tests/test-bundle2-exchange.t Wed Apr 15 01:16:40 2015 -0400 @@ -226,7 +226,6 @@ remote: adding file changes remote: added 1 changesets with 0 changes to 0 files (-1 heads) remote: 1 new obsolescence markers - remote: "wlock" acquired after "lock" at: */mercurial/bookmarks.py:259 (pushbookmark) (glob) updating bookmark book_eea1 pre-close-tip:02de42196ebe draft book_02de postclose-tip:02de42196ebe draft book_02de @@ -305,7 +304,6 @@ remote: adding file changes remote: added 1 changesets with 1 changes to 1 files remote: 1 new obsolescence markers - remote: "wlock" acquired after "lock" at: */mercurial/bookmarks.py:259 (pushbookmark) (glob) updating bookmark book_5fdd remote: pre-close-tip:5fddd98957c8 draft book_5fdd remote: pushkey: lock state after "bookmarks" @@ -357,7 +355,6 @@ remote: adding file changes remote: added 1 changesets with 1 changes to 1 files remote: 1 new obsolescence markers - remote: "wlock" acquired after "lock" at: */mercurial/bookmarks.py:259 (pushbookmark) (glob) updating bookmark book_32af pre-close-tip:02de42196ebe draft book_02de postclose-tip:02de42196ebe draft book_02de