D3988: resolve: add confirm config option
khanchi97 (Sushil khanchi)
phabricator at mercurial-scm.org
Fri Aug 3 10:28:01 EDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf8732e33bcbc: resolve: add confirm config option (authored by khanchi97, committed by ).
CHANGED PRIOR TO COMMIT
https://phab.mercurial-scm.org/D3988?vs=9816&id=9823#toc
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D3988?vs=9816&id=9823
REVISION DETAIL
https://phab.mercurial-scm.org/D3988
AFFECTED FILES
mercurial/commands.py
mercurial/configitems.py
mercurial/help/config.txt
tests/test-resolve.t
CHANGE DETAILS
diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -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 ..
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -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)
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -190,6 +190,9 @@
coreconfigitem('commands', 'grep.all-files',
default=False,
)
+coreconfigitem('commands', 'resolve.confirm',
+ default=False,
+)
coreconfigitem('commands', 'show.aliasprefix',
default=list,
)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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:
To: khanchi97, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
More information about the Mercurial-devel
mailing list