diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -10,6 +10,7 @@ from node import hex, nullid 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 @@ def unbundle(repo, cg, heads, source, ur 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 @@ def unbundle(repo, cg, heads, source, ur 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 --git a/tests/test-bundle2-exchange.t b/tests/test-bundle2-exchange.t --- a/tests/test-bundle2-exchange.t +++ b/tests/test-bundle2-exchange.t @@ -226,7 +226,6 @@ push 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 @@ push over ssh 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 @@ push over http 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