# HG changeset patch # User Steve Borho # Date 2010-10-16 04:00:45 # Node ID 05bd2658bbb3cbb5f2008e96a049fe0dfa45ff5e # Parent 338b4b615d33e19e208441a6fdce1bdbd56c08a1 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. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2563,11 +2563,17 @@ def merge(ui, repo, node=None, **opts): 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 @@ def merge(ui, repo, node=None, **opts): 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 @@ def resolve(ui, repo, *pats, **opts): 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 @@ def resolve(ui, repo, *pats, **opts): 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 @@ table = { "^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 @@ table = { ('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]...')), diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t --- a/tests/test-debugcomplete.t +++ b/tests/test-debugcomplete.t @@ -186,7 +186,7 @@ Show all commands + options 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 @@ Show all commands + options 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: