changeset 27287:c9ceea3f2d8e

shelve: widen wlock scope of unshelve for consistency while processing Before this patch, "hg unshelve" of shelve extension executes below before acquisition of wlock: - cmdutil.checkunfinished() - examine existence of (specified) shelve file It may cause unintentional result, if another command runs parallelly (see also issue4368). This patch widens wlock scope of "hg unshelve" of shelve extension for consistency while processing.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 09 Dec 2015 08:28:53 +0900
parents 528cf1a73ae5
children c14af2d4b08c
files hgext/shelve.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/shelve.py	Sun Dec 06 17:07:50 2015 -0800
+++ b/hgext/shelve.py	Wed Dec 09 08:28:53 2015 +0900
@@ -616,6 +616,13 @@
        than ``maxbackups`` backups are kept, if same timestamp
        prevents from deciding exact order of them, for safety.
     """
+    wlock = repo.wlock()
+    try:
+        return _dounshelve(ui, repo, *shelved, **opts)
+    finally:
+        lockmod.release(wlock)
+
+def _dounshelve(ui, repo, *shelved, **opts):
     abortf = opts['abort']
     continuef = opts['continue']
     if not abortf and not continuef:
@@ -656,11 +663,10 @@
         raise error.Abort(_("shelved change '%s' not found") % basename)
 
     oldquiet = ui.quiet
-    wlock = lock = tr = None
+    lock = tr = None
     forcemerge = ui.backupconfig('ui', 'forcemerge')
     try:
         ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'unshelve')
-        wlock = repo.wlock()
         lock = repo.lock()
 
         tr = repo.transaction('unshelve', report=lambda x: None)
@@ -755,7 +761,7 @@
         ui.quiet = oldquiet
         if tr:
             tr.release()
-        lockmod.release(lock, wlock)
+        lockmod.release(lock)
         ui.restoreconfig(forcemerge)
 
 @command('shelve',