[PATCH 3 of 3] commands: get rid of empty try/finally block from _dograft
Augie Fackler
raf at durin42.com
Tue Jan 12 02:58:00 UTC 2016
On Mon, Jan 11, 2016 at 09:50:35AM -0800, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bos at serpentine.com>
> # Date 1452534588 28800
> # Mon Jan 11 09:49:48 2016 -0800
> # Node ID ee14884fe075fac178cfc39e707ef94ab8c2a743
> # Parent 163832ad8661631960c31af659836bfdc2aa9e9d
> commands: get rid of empty try/finally block from _dograft
queud these, thanks
>
> This diff is purely an indentation change to clean up a block that
> was kept in place to make 77995317b374 easier to read.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -3998,75 +3998,70 @@ def _dograft(ui, repo, *revs, **opts):
> if not revs:
> return -1
>
> - try:
> - for pos, ctx in enumerate(repo.set("%ld", revs)):
> - desc = '%d:%s "%s"' % (ctx.rev(), ctx,
> - ctx.description().split('\n', 1)[0])
> - names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
> - if names:
> - desc += ' (%s)' % ' '.join(names)
> - ui.status(_('grafting %s\n') % desc)
> - if opts.get('dry_run'):
> - continue
> -
> - extra = ctx.extra().copy()
> - del extra['branch']
> - source = extra.get('source')
> - if source:
> - extra['intermediate-source'] = ctx.hex()
> - else:
> - extra['source'] = ctx.hex()
> - user = ctx.user()
> - if opts.get('user'):
> - user = opts['user']
> - date = ctx.date()
> - if opts.get('date'):
> - date = opts['date']
> - message = ctx.description()
> - if opts.get('log'):
> - message += '\n(grafted from %s)' % ctx.hex()
> -
> - # we don't merge the first commit when continuing
> - if not cont:
> - # perform the graft merge with p1(rev) as 'ancestor'
> - try:
> - # ui.forcemerge is an internal variable, do not document
> - repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
> - 'graft')
> - stats = mergemod.graft(repo, ctx, ctx.p1(),
> - ['local', 'graft'])
> - finally:
> - repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
> - # report any conflicts
> - if stats and stats[3] > 0:
> - # write out state for --continue
> - nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
> - repo.vfs.write('graftstate', ''.join(nodelines))
> - extra = ''
> - if opts.get('user'):
> - extra += ' --user %s' % opts['user']
> - if opts.get('date'):
> - extra += ' --date %s' % opts['date']
> - if opts.get('log'):
> - extra += ' --log'
> - hint=_('use hg resolve and hg graft --continue%s') % extra
> - raise error.Abort(
> - _("unresolved conflicts, can't continue"),
> - hint=hint)
> - else:
> - cont = False
> -
> - # commit
> - node = repo.commit(text=message, user=user,
> - date=date, extra=extra, editor=editor)
> - if node is None:
> - ui.warn(
> - _('note: graft of %d:%s created no changes to commit\n') %
> - (ctx.rev(), ctx))
> - finally:
> - # TODO: get rid of this meaningless try/finally enclosing.
> - # this is kept only to reduce changes in a patch.
> - pass
> + for pos, ctx in enumerate(repo.set("%ld", revs)):
> + desc = '%d:%s "%s"' % (ctx.rev(), ctx,
> + ctx.description().split('\n', 1)[0])
> + names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
> + if names:
> + desc += ' (%s)' % ' '.join(names)
> + ui.status(_('grafting %s\n') % desc)
> + if opts.get('dry_run'):
> + continue
> +
> + extra = ctx.extra().copy()
> + del extra['branch']
> + source = extra.get('source')
> + if source:
> + extra['intermediate-source'] = ctx.hex()
> + else:
> + extra['source'] = ctx.hex()
> + user = ctx.user()
> + if opts.get('user'):
> + user = opts['user']
> + date = ctx.date()
> + if opts.get('date'):
> + date = opts['date']
> + message = ctx.description()
> + if opts.get('log'):
> + message += '\n(grafted from %s)' % ctx.hex()
> +
> + # we don't merge the first commit when continuing
> + if not cont:
> + # perform the graft merge with p1(rev) as 'ancestor'
> + try:
> + # ui.forcemerge is an internal variable, do not document
> + repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
> + 'graft')
> + stats = mergemod.graft(repo, ctx, ctx.p1(),
> + ['local', 'graft'])
> + finally:
> + repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
> + # report any conflicts
> + if stats and stats[3] > 0:
> + # write out state for --continue
> + nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
> + repo.vfs.write('graftstate', ''.join(nodelines))
> + extra = ''
> + if opts.get('user'):
> + extra += ' --user %s' % opts['user']
> + if opts.get('date'):
> + extra += ' --date %s' % opts['date']
> + if opts.get('log'):
> + extra += ' --log'
> + hint=_('use hg resolve and hg graft --continue%s') % extra
> + raise error.Abort(
> + _("unresolved conflicts, can't continue"),
> + hint=hint)
> + else:
> + cont = False
> +
> + # commit
> + node = repo.commit(text=message, user=user,
> + date=date, extra=extra, editor=editor)
> + if node is None:
> + ui.warn(
> + _('note: graft of %d:%s created no changes to commit\n') %
> + (ctx.rev(), ctx))
>
> # remove state when we complete successfully
> if not opts.get('dry_run'):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list