From patchwork Tue Dec 1 18:18:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6, of, 9, STABLE] shelve: widen wlock scope of shelve for consistency while processing From: Katsunori FUJIWARA X-Patchwork-Id: 11717 Message-Id: <064cd627433570e5efc7.1448993924@feefifofum> To: mercurial-devel@selenic.com Date: Wed, 02 Dec 2015 03:18:44 +0900 # HG changeset patch # User FUJIWARA Katsunori # Date 1448993528 -32400 # Wed Dec 02 03:12:08 2015 +0900 # Branch stable # Node ID 064cd627433570e5efc70c9de69d68d278a13bb9 # Parent e6dc1867c9b7fb47de43087bdaacbcd148430033 shelve: widen wlock scope of shelve for consistency while processing Before this patch, "hg shelve" of shelve extension executes/refers below before acquisition of wlock: - 'repo.dirstate.parents()' via 'repo[None].parents()' - 'repo._activebookmark' It may cause unintentional result, if another command runs parallelly (see also issue4368). This patch widens wlock scope of "hg shelve" of shelve extension for consistency while processing. diff --git a/hgext/shelve.py b/hgext/shelve.py --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -224,7 +224,13 @@ def _aborttransaction(repo): def createcmd(ui, repo, pats, opts): """subcommand that creates a new shelve""" - + wlock = repo.wlock() + try: + return _docreatecmd(ui, repo, pats, opts) + finally: + lockmod.release(wlock) + +def _docreatecmd(ui, repo, pats, opts): def mutableancestors(ctx): """return all mutable ancestors for ctx (included) @@ -285,9 +291,8 @@ def createcmd(ui, repo, pats, opts): name = opts['name'] - wlock = lock = tr = None - try: - wlock = repo.wlock() + lock = tr = None + try: lock = repo.lock() # use an uncommitted transaction to generate the bundle to avoid @@ -346,7 +351,7 @@ def createcmd(ui, repo, pats, opts): _aborttransaction(repo) finally: - lockmod.release(tr, lock, wlock) + lockmod.release(tr, lock) def cleanupcmd(ui, repo): """subcommand that deletes all shelves"""