shelve: widen wlock scope of shelve for consistency while processing
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Wed, 02 Dec 2015 03:12:08 +0900
changeset 27197 6df3ec5bb813
parent 27196 7b4a61570d61
child 27198 7df042d0784f
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.
hgext/shelve.py
--- a/hgext/shelve.py	Wed Dec 02 03:12:08 2015 +0900
+++ b/hgext/shelve.py	Wed Dec 02 03:12:08 2015 +0900
@@ -224,7 +224,13 @@
 
 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 @@
 
     name = opts['name']
 
-    wlock = lock = tr = None
+    lock = tr = None
     try:
-        wlock = repo.wlock()
         lock = repo.lock()
 
         # use an uncommitted transaction to generate the bundle to avoid
@@ -346,7 +351,7 @@
 
         _aborttransaction(repo)
     finally:
-        lockmod.release(tr, lock, wlock)
+        lockmod.release(tr, lock)
 
 def cleanupcmd(ui, repo):
     """subcommand that deletes all shelves"""