merge: add --tool argument to merge and resolve
These arguments are shorthand for --config ui.merge, but they also
override HGMERGE if it is found in the user's environment.
--- a/mercurial/commands.py Sun Oct 17 14:00:01 2010 +0300
+++ b/mercurial/commands.py Fri Oct 15 23:00:45 2010 -0500
@@ -2563,11 +2563,17 @@
updates to the repository are allowed. The next commit will have
two parents.
+ ``--tool`` can be used to specify the merge tool used for file
+ merges. It overrides the HGMERGE environment variable and your
+ configuration files.
+
If no revision is specified, the working directory's parent is a
head revision, and the current branch contains exactly one other
head, the other head is merged with by default. Otherwise, an
explicit revision with which to merge with must be provided.
+ :hg:`resolve` must be used to resolve unresolved files.
+
To undo an uncommitted merge, use :hg:`update --clean .` which
will check out a clean copy of the original merge parent, losing
all changes.
@@ -2580,6 +2586,12 @@
if not node:
node = opts.get('rev')
+ t = opts.get('tool')
+ if t:
+ if 'HGMERGE' in os.environ:
+ os.environ['HGMERGE'] = t
+ ui.setconfig('ui', 'merge', t)
+
if not node:
branch = repo.changectx(None).branch()
bheads = repo.branchheads(branch)
@@ -2932,10 +2944,12 @@
The resolve command can be used in the following ways:
- - :hg:`resolve FILE...`: attempt to re-merge the specified files,
- discarding any previous merge attempts. Re-merging is not
+ - :hg:`resolve [--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 selects all unresolved files.
+ to selects 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.
- :hg:`resolve -m [FILE]`: mark a file as having been resolved
(e.g. after having manually fixed-up the files). The default is
@@ -2965,6 +2979,12 @@
raise util.Abort(_('no files or directories specified; '
'use --all to remerge all files'))
+ t = opts.get('tool')
+ if t:
+ if 'HGMERGE' in os.environ:
+ os.environ['HGMERGE'] = t
+ ui.setconfig('ui', 'merge', t)
+
ms = mergemod.mergestate(repo)
m = cmdutil.match(repo, pats, opts)
ret = 0
@@ -4270,6 +4290,7 @@
"^merge":
(merge,
[('f', 'force', None, _('force a merge with outstanding changes')),
+ ('t', 'tool', '', _('specify merge tool')),
('r', 'rev', '',
_('revision to merge'), _('REV')),
('P', 'preview', None,
@@ -4338,6 +4359,7 @@
('l', 'list', None, _('list state of files needing merge')),
('m', 'mark', None, _('mark files as resolved')),
('u', 'unmark', None, _('mark files as unresolved')),
+ ('t', 'tool', '', _('specify merge tool')),
('n', 'no-status', None, _('hide status prefix'))]
+ walkopts,
_('[OPTION]... [FILE]...')),
--- a/tests/test-debugcomplete.t Sun Oct 17 14:00:01 2010 +0300
+++ b/tests/test-debugcomplete.t Fri Oct 15 23:00:45 2010 -0500
@@ -186,7 +186,7 @@
forget: include, exclude
init: ssh, remotecmd
log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, style, template, include, exclude
- merge: force, rev, preview
+ merge: force, tool, rev, preview
pull: update, force, rev, branch, ssh, remotecmd
push: force, rev, branch, new-branch, ssh, remotecmd
remove: after, force, include, exclude
@@ -236,7 +236,7 @@
paths:
recover:
rename: after, force, include, exclude, dry-run
- resolve: all, list, mark, unmark, no-status, include, exclude
+ resolve: all, list, mark, unmark, tool, no-status, include, exclude
revert: all, date, rev, no-backup, include, exclude, dry-run
rollback: dry-run
root: