Mercurial > hg
changeset 38822:f8732e33bcbc
resolve: add confirm config option
This config setting gives a functionality to confirm before
it re-merge all unresolved files. If this config is enabled,
when you run 'hg resolve --all' it will prompt with a msg
"re-merge all unresolved files (yn)?"
To enable this functionality:
[commands]
resolve.confirm = True
Differential Revision: https://phab.mercurial-scm.org/D3988
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Tue, 31 Jul 2018 19:11:17 +0530 |
parents | d814bbd22946 |
children | a9a4b0fc1e5d |
files | mercurial/commands.py mercurial/configitems.py mercurial/help/config.txt tests/test-resolve.t |
diffstat | 4 files changed, 103 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Jul 17 23:34:55 2018 -0700 +++ b/mercurial/commands.py Tue Jul 31 19:11:17 2018 +0530 @@ -4529,10 +4529,16 @@ """ opts = pycompat.byteskwargs(opts) + confirm = ui.configbool('commands', 'resolve.confirm') flaglist = 'all mark unmark list no_status'.split() all, mark, unmark, show, nostatus = \ [opts.get(o) for o in flaglist] + if all and confirm: + if ui.promptchoice(_(b're-merge all unresolved files (yn)?' + b'$$ &Yes $$ &No')): + raise error.Abort(_('user quit')) + if (show and (mark or unmark)) or (mark and unmark): raise error.Abort(_("too many options specified")) if pats and all:
--- a/mercurial/configitems.py Tue Jul 17 23:34:55 2018 -0700 +++ b/mercurial/configitems.py Tue Jul 31 19:11:17 2018 +0530 @@ -190,6 +190,9 @@ coreconfigitem('commands', 'grep.all-files', default=False, ) +coreconfigitem('commands', 'resolve.confirm', + default=False, +) coreconfigitem('commands', 'show.aliasprefix', default=list, )
--- a/mercurial/help/config.txt Tue Jul 17 23:34:55 2018 -0700 +++ b/mercurial/help/config.txt Tue Jul 31 19:11:17 2018 +0530 @@ -438,6 +438,11 @@ ``commands`` ------------ +``resolve.confirm`` + Confirm before re-merging all unresolved files when running + :hg:`resolve --all`. + (default: False) + ``status.relative`` Make paths in :hg:`status` output relative to the current directory. (default: False)
--- a/tests/test-resolve.t Tue Jul 17 23:34:55 2018 -0700 +++ b/tests/test-resolve.t Tue Jul 31 19:11:17 2018 +0530 @@ -423,3 +423,92 @@ R file2 $ cd .. + +====================================================== +Test 'hg resolve' confirm config option functionality | +====================================================== + $ cat >> $HGRCPATH << EOF + > [extensions] + > rebase= + > EOF + + $ hg init repo2 + $ cd repo2 + + $ echo boss > boss + $ hg ci -Am "add boss" + adding boss + + $ for emp in emp1 emp2 emp3; do echo work > $emp; done; + $ hg ci -Aqm "added emp1 emp2 emp3" + + $ hg up 0 + 0 files updated, 0 files merged, 3 files removed, 0 files unresolved + + $ for emp in emp1 emp2 emp3; do echo nowork > $emp; done; + $ hg ci -Aqm "added lazy emp1 emp2 emp3" + + $ hg log -GT "{rev} {node|short} {firstline(desc)}\n" + @ 2 0acfd4a49af0 added lazy emp1 emp2 emp3 + | + | o 1 f30f98a8181f added emp1 emp2 emp3 + |/ + o 0 88660038d466 add boss + + $ hg rebase -s 1 -d 2 + rebasing 1:f30f98a8181f "added emp1 emp2 emp3" + merging emp1 + merging emp2 + merging emp3 + warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark') + warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark') + warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark') + unresolved conflicts (see hg resolve, then hg rebase --continue) + [1] + +Test when commands.resolve.confirm config option is not set: +=========================================================== + $ hg resolve --all + merging emp1 + merging emp2 + merging emp3 + warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark') + warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark') + warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark') + [1] + +Test when config option is set: +============================== + $ cat >> $HGRCPATH << EOF + > [ui] + > interactive = True + > [commands] + > resolve.confirm = True + > EOF + + $ hg resolve + abort: no files or directories specified + (use --all to re-merge all unresolved files) + [255] + $ hg resolve --all << EOF + > n + > EOF + re-merge all unresolved files (yn)? n + abort: user quit + [255] + + $ hg resolve --all << EOF + > y + > EOF + re-merge all unresolved files (yn)? y + merging emp1 + merging emp2 + merging emp3 + warning: conflicts while merging emp1! (edit, then use 'hg resolve --mark') + warning: conflicts while merging emp2! (edit, then use 'hg resolve --mark') + warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark') + [1] + + $ hg rebase --abort + rebase aborted + $ cd ..