resolve: add a flag for the default behavior of re-merging
On its own, it's not useful, but the next commit will add an hgrc
config option to make it mandatory.
There is no short option, as -r almost always means --rev and this
option doesn't seem like it would be so common as to mandate a short
option.
Differential Revision: https://phab.mercurial-scm.org/D4378
--- a/mercurial/commands.py Sat Sep 01 02:01:55 2018 -0400
+++ b/mercurial/commands.py Sun Aug 26 15:52:34 2018 -0400
@@ -4506,7 +4506,8 @@
('l', 'list', None, _('list state of files needing merge')),
('m', 'mark', None, _('mark files as resolved')),
('u', 'unmark', None, _('mark files as unresolved')),
- ('n', 'no-status', None, _('hide status prefix'))]
+ ('n', 'no-status', None, _('hide status prefix')),
+ ('', 're-merge', None, _('re-merge files'))]
+ mergetoolopts + walkopts + formatteropts,
_('[OPTION]... [FILE]...'),
inferrepo=True)
@@ -4523,9 +4524,9 @@
The resolve command can be used in the following ways:
- - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
- files, discarding any previous merge attempts. Re-merging is not
- performed for files already marked as resolved. Use ``--all/-a``
+ - :hg:`resolve [--re-merge] [--tool TOOL] FILE...`: attempt to re-merge
+ the specified files, discarding any previous merge attempts. Re-merging
+ is not performed for files already marked as resolved. Use ``--all/-a``
to select all unresolved files. ``--tool`` can be used to specify
the merge tool used for the given files. It overrides the HGMERGE
environment variable and your configuration files. Previous file
@@ -4554,11 +4555,11 @@
opts = pycompat.byteskwargs(opts)
confirm = ui.configbool('commands', 'resolve.confirm')
- flaglist = 'all mark unmark list no_status'.split()
- all, mark, unmark, show, nostatus = \
+ flaglist = 'all mark unmark list no_status re_merge'.split()
+ all, mark, unmark, show, nostatus, remerge = \
[opts.get(o) for o in flaglist]
- if len(list(filter(None, [show, mark, unmark]))) > 1:
+ if len(list(filter(None, [show, mark, unmark, remerge]))) > 1:
raise error.Abort(_("too many options specified"))
if pats and all:
raise error.Abort(_("can't specify --all and patterns"))
@@ -4752,8 +4753,11 @@
for f in ms:
if not m(f):
continue
- flags = ''.join(['-%s ' % o[0:1] for o in flaglist
- if opts.get(o)])
+ def flag(o):
+ if o == 're_merge':
+ return '--re-merge '
+ return '-%s ' % o[0:1]
+ flags = ''.join([flag(o) for o in flaglist if opts.get(o)])
hint = _("(try: hg resolve %s%s)\n") % (
flags,
' '.join(pats))
--- a/tests/test-completion.t Sat Sep 01 02:01:55 2018 -0400
+++ b/tests/test-completion.t Sun Aug 26 15:52:34 2018 -0400
@@ -331,7 +331,7 @@
phase: public, draft, secret, force, rev
recover:
rename: after, force, include, exclude, dry-run
- resolve: all, list, mark, unmark, no-status, tool, include, exclude, template
+ resolve: all, list, mark, unmark, no-status, re-merge, tool, include, exclude, template
revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
rollback: dry-run, force
root:
--- a/tests/test-resolve.t Sat Sep 01 02:01:55 2018 -0400
+++ b/tests/test-resolve.t Sun Aug 26 15:52:34 2018 -0400
@@ -442,6 +442,18 @@
$ hg resolve -l
R file1
R file2
+Testing the --re-merge flag
+ $ hg resolve --unmark file1
+ $ hg resolve -l
+ U file1
+ R file2
+ $ hg resolve --mark --re-merge
+ abort: too many options specified
+ [255]
+ $ hg resolve --re-merge --all
+ merging file1
+ warning: conflicts while merging file1! (edit, then use 'hg resolve --mark')
+ [1]
$ cd ..