commands: execute checkunfinished and bailifchanged inside wlock scope
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Wed, 02 Dec 2015 03:12:08 +0900
changeset 27195 84de71ec5c61
parent 27194 77995317b374
child 27196 7b4a61570d61
commands: execute checkunfinished and bailifchanged inside wlock scope Before this patch, "hg import" executes below before acquisition of wlock: - cmdutil.checkunfinished() - cmdutil.bailifchanged() It may cause unintentional result, if another command runs parallelly (see also issue4368). To avoid this issue, this patch executes 'cmdutil.checkunfinished()' and 'cmdutil.bailifchanged()' inside wlock scope of "hg import".
mercurial/commands.py
--- a/mercurial/commands.py	Wed Dec 02 03:12:07 2015 +0900
+++ b/mercurial/commands.py	Wed Dec 02 03:12:08 2015 +0900
@@ -4557,11 +4557,6 @@
     if opts.get('exact') and opts.get('prefix'):
         raise error.Abort(_('cannot use --exact with --prefix'))
 
-    if update:
-        cmdutil.checkunfinished(repo)
-    if (opts.get('exact') or not opts.get('force')) and update:
-        cmdutil.bailifchanged(repo)
-
     base = opts["base"]
     wlock = dsguard = lock = tr = None
     msgs = []
@@ -4571,6 +4566,12 @@
     try:
         try:
             wlock = repo.wlock()
+
+            if update:
+                cmdutil.checkunfinished(repo)
+            if (opts.get('exact') or not opts.get('force')) and update:
+                cmdutil.bailifchanged(repo)
+
             if not opts.get('no_commit'):
                 lock = repo.lock()
                 tr = repo.transaction('import')