# HG changeset patch # User Valentin Gatien-Baron # Date 1535316148 14400 # Node ID 56469d475341084dfd6c6571e45c35040f167fe9 # Parent 5d00e6061ba255962fadbc2c44b3e87caa7f5f69 resolve: add config to make hg resolve not re-merge by default Before this, calling 'hg resolve' with neither -m, -u or -l will re-merge. This is highly error prone (it's easy to forget to forget a -m), and pretty bad when it happens (many people have no idea 'hg resolve' can re-merge, and end up redoing the work of resolving all the conflicts, because they have no idea there was a backup of their work). Differential Revision: https://phab.mercurial-scm.org/D4379 diff -r 5d00e6061ba2 -r 56469d475341 mercurial/commands.py --- a/mercurial/commands.py Sun Aug 26 15:52:34 2018 -0400 +++ b/mercurial/commands.py Sun Aug 26 16:42:28 2018 -0400 @@ -4559,8 +4559,13 @@ all, mark, unmark, show, nostatus, remerge = \ [opts.get(o) for o in flaglist] - if len(list(filter(None, [show, mark, unmark, remerge]))) > 1: - raise error.Abort(_("too many options specified")) + actioncount = len(list(filter(None, [show, mark, unmark, remerge]))) + if actioncount > 1: + raise error.Abort(_("too many actions specified")) + elif (actioncount == 0 + and ui.config('commands', 'resolve.explicit-re-merge')): + hint = _('use --mark, --unmark, --list or --re-merge') + raise error.Abort(_('no action specified'), hint=hint) if pats and all: raise error.Abort(_("can't specify --all and patterns")) if not (all or pats or show or mark or unmark): diff -r 5d00e6061ba2 -r 56469d475341 mercurial/configitems.py --- a/mercurial/configitems.py Sun Aug 26 15:52:34 2018 -0400 +++ b/mercurial/configitems.py Sun Aug 26 16:42:28 2018 -0400 @@ -193,6 +193,9 @@ coreconfigitem('commands', 'resolve.confirm', default=False, ) +coreconfigitem('commands', 'resolve.explicit-re-merge', + default=False, +) coreconfigitem('commands', 'resolve.mark-check', default='none', ) diff -r 5d00e6061ba2 -r 56469d475341 mercurial/help/config.txt --- a/mercurial/help/config.txt Sun Aug 26 15:52:34 2018 -0400 +++ b/mercurial/help/config.txt Sun Aug 26 16:42:28 2018 -0400 @@ -442,6 +442,11 @@ Confirm before performing action if no filename is passed. (default: False) +``resolve.explicit-re-merge`` + Require uses of ``hg resolve`` to specify which action it should perform, + instead of re-merging files by default. + (default: False) + ``resolve.mark-check`` Determines what level of checking :hg:`resolve --mark` will perform before marking files as resolved. Valid values are ``none`, ``warn``, and diff -r 5d00e6061ba2 -r 56469d475341 tests/test-resolve.t --- a/tests/test-resolve.t Sun Aug 26 15:52:34 2018 -0400 +++ b/tests/test-resolve.t Sun Aug 26 16:42:28 2018 -0400 @@ -448,12 +448,22 @@ U file1 R file2 $ hg resolve --mark --re-merge - abort: too many options specified + abort: too many actions specified [255] $ hg resolve --re-merge --all merging file1 warning: conflicts while merging file1! (edit, then use 'hg resolve --mark') [1] +Explicit re-merge + $ hg resolve --unmark file1 + $ hg resolve --config commands.resolve.explicit-re-merge=1 --all + abort: no action specified + (use --mark, --unmark, --list or --re-merge) + [255] + $ hg resolve --config commands.resolve.explicit-re-merge=1 --re-merge --all + merging file1 + warning: conflicts while merging file1! (edit, then use 'hg resolve --mark') + [1] $ cd ..