commands: widen wlock scope of graft for consitency while processing
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Wed, 02 Dec 2015 03:12:07 +0900
changeset 27194 77995317b374
parent 27193 c7217f1458bf
child 27195 84de71ec5c61
commands: widen wlock scope of graft for consitency while processing Before this patch, "hg graft" executes below before acquisition of wlock. - cmdutil.checkunfinished() - cmdutil.bailifchanged() - repo.dirstate.parents() via 'repo["."]' - unlinking '.hg/graftstate' It may cause unintentional result, if another command runs parallelly (see also issue4368). This patch widens wlock scope of "hg graft" for consitency while processing.
mercurial/commands.py
--- a/mercurial/commands.py	Wed Dec 02 03:12:07 2015 +0900
+++ b/mercurial/commands.py	Wed Dec 02 03:12:07 2015 +0900
@@ -3731,7 +3731,14 @@
 
     Returns 0 on successful completion.
     '''
-
+    wlock = None
+    try:
+        wlock = repo.wlock()
+        return _dograft(ui, repo, *revs, **opts)
+    finally:
+        release(wlock)
+
+def _dograft(ui, repo, *revs, **opts):
     revs = list(revs)
     revs.extend(opts['rev'])
 
@@ -3837,7 +3844,6 @@
         if not revs:
             return -1
 
-    wlock = repo.wlock()
     try:
         for pos, ctx in enumerate(repo.set("%ld", revs)):
             desc = '%d:%s "%s"' % (ctx.rev(), ctx,
@@ -3904,7 +3910,9 @@
                     _('note: graft of %d:%s created no changes to commit\n') %
                     (ctx.rev(), ctx))
     finally:
-        wlock.release()
+        # TODO: get rid of this meaningless try/finally enclosing.
+        # this is kept only to reduce changes in a patch.
+        pass
 
     # remove state when we complete successfully
     if not opts.get('dry_run'):