D3870: rebase: add --confirm option
yuja (Yuya Nishihara)
phabricator at mercurial-scm.org
Tue Jul 10 09:18:18 EDT 2018
yuja added a comment.
This can't be applied, can you rebase?
> - a/hgext/rebase.py +++ b/hgext/rebase.py @@ -677,7 +677,7 @@ ('a', 'abort', False, _('abort an interrupted rebase')), ('', 'auto-orphans', '', _('automatically rebase orphan revisions ' 'in the specified revset (EXPERIMENTAL)')),
> - ] + cmdutil.dryrunopts + cmdutil.formatteropts, + ] + cmdutil.dryrunopts + cmdutil.formatteropts + cmdutil.confirmopts, _('[-s REV | -b REV] [-d REV] [OPTION]')) def rebase(ui, repo, **opts): """move changeset (and descendants) to a different branch @@ -808,6 +808,10 @@ raise error.Abort(_('cannot specify both --dry-run and --abort')) if opts.get('continue'): raise error.Abort(_('cannot specify both --dry-run and --continue')) + if opts.get('confirm'): + raise error.Abort(_('cannot specify both --dry-run and --confirm')) + if opts.get('confirm'): + dryrun = True
Nit: we'll have to reject "--confirm --abort" and "--confirm --continue" as
well.
> with repo.wlock(), repo.lock():
> try:
> overrides = {('rebase', 'singletransaction'): True}
> with ui.configoverride(overrides, 'rebase'):
> _origrebase(ui, repo, opts, rbsrt, inmemory=True,
> leaveunfinished=True, supptrwarns=True)
> except error.InMemoryMergeConflictsError:
>
> + conflict = True
>
> ui.status(_('hit a merge conflict\n'))
> return 1
> else:
>
> - ui.status(_('dry-run rebase completed successfully; run without '
> - '-n/--dry-run to perform this rebase\n')) + conflict = False + if confirm: + ui.status(_('rebase completed successfully\n')) + else: + ui.status(_('dry-run rebase completed successfully; run without' + ' -n/--dry-run to perform this rebase\n')) return 0 finally:
> - # no need to store backup in case of dryrun
> - rbsrt._prepareabortorcontinue(isabort=True, backup=False,
> - suppwarns=True) + if confirm and not ui.promptchoice(_(b'apply changes (yn)?' + b'$$ &Yes $$ &No')): + if conflict: + rbsrt._prepareabortorcontinue(isabort=True, + backup=False, + suppwarns=True) + _dorebase(ui, repo, opts, inmemory=False) + else: + # finish unfinished rebase + rbsrt._finishrebase()
I'm not a fan of doing much things "finally:" clause. Can you move this to
the "else:" clause? The "conflict" flag can be flipped to be a "needsabort",
and it has to be initialized before "try:".
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D3870
To: khanchi97, #hg-reviewers
Cc: yuja, mercurial-devel
More information about the Mercurial-devel
mailing list