Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 27194:77995317b374
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.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 02 Dec 2015 03:12:07 +0900 |
parents | c7217f1458bf |
children | 84de71ec5c61 |
comparison
equal
deleted
inserted
replaced
27193:c7217f1458bf | 27194:77995317b374 |
---|---|
3729 See :hg:`help revisions` and :hg:`help revsets` for more about | 3729 See :hg:`help revisions` and :hg:`help revsets` for more about |
3730 specifying revisions. | 3730 specifying revisions. |
3731 | 3731 |
3732 Returns 0 on successful completion. | 3732 Returns 0 on successful completion. |
3733 ''' | 3733 ''' |
3734 | 3734 wlock = None |
3735 try: | |
3736 wlock = repo.wlock() | |
3737 return _dograft(ui, repo, *revs, **opts) | |
3738 finally: | |
3739 release(wlock) | |
3740 | |
3741 def _dograft(ui, repo, *revs, **opts): | |
3735 revs = list(revs) | 3742 revs = list(revs) |
3736 revs.extend(opts['rev']) | 3743 revs.extend(opts['rev']) |
3737 | 3744 |
3738 if not opts.get('user') and opts.get('currentuser'): | 3745 if not opts.get('user') and opts.get('currentuser'): |
3739 opts['user'] = ui.username() | 3746 opts['user'] = ui.username() |
3835 (r, repo[r], rev, ctx)) | 3842 (r, repo[r], rev, ctx)) |
3836 revs.remove(r) | 3843 revs.remove(r) |
3837 if not revs: | 3844 if not revs: |
3838 return -1 | 3845 return -1 |
3839 | 3846 |
3840 wlock = repo.wlock() | |
3841 try: | 3847 try: |
3842 for pos, ctx in enumerate(repo.set("%ld", revs)): | 3848 for pos, ctx in enumerate(repo.set("%ld", revs)): |
3843 desc = '%d:%s "%s"' % (ctx.rev(), ctx, | 3849 desc = '%d:%s "%s"' % (ctx.rev(), ctx, |
3844 ctx.description().split('\n', 1)[0]) | 3850 ctx.description().split('\n', 1)[0]) |
3845 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) | 3851 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) |
3902 if node is None: | 3908 if node is None: |
3903 ui.warn( | 3909 ui.warn( |
3904 _('note: graft of %d:%s created no changes to commit\n') % | 3910 _('note: graft of %d:%s created no changes to commit\n') % |
3905 (ctx.rev(), ctx)) | 3911 (ctx.rev(), ctx)) |
3906 finally: | 3912 finally: |
3907 wlock.release() | 3913 # TODO: get rid of this meaningless try/finally enclosing. |
3914 # this is kept only to reduce changes in a patch. | |
3915 pass | |
3908 | 3916 |
3909 # remove state when we complete successfully | 3917 # remove state when we complete successfully |
3910 if not opts.get('dry_run'): | 3918 if not opts.get('dry_run'): |
3911 util.unlinkpath(repo.join('graftstate'), ignoremissing=True) | 3919 util.unlinkpath(repo.join('graftstate'), ignoremissing=True) |
3912 | 3920 |