D4379: resolve: add config to make hg resolve not re-merge by default
valentin.gatienbaron (Valentin Gatien-Baron)
phabricator at mercurial-scm.org
Sun Aug 26 23:02:21 UTC 2018
valentin.gatienbaron created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
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).
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4379
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
@@ -442,6 +442,13 @@
$ hg resolve -l
R file1
R file2
+Explicit re-merge
+ $ 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
+ (no more unresolved files)
$ cd ..
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -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 --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -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 --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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):
To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list