# HG changeset patch # User FUJIWARA Katsunori # Date 2015-12-01 18:12:07 # Node ID 77995317b374c15ff10cd479a86503bf0059bd94 # Parent c7217f1458bf37379d0486712c85cad2bf1ca85b 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. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3731,7 +3731,14 @@ def graft(ui, repo, *revs, **opts): 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 @@ def graft(ui, repo, *revs, **opts): 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 @@ def graft(ui, repo, *revs, **opts): _('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'):