[PATCH] merge: add --tool argument to merge and resolve

Steve Borho steve at borho.org
Fri Oct 15 23:28:42 CDT 2010


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1287201645 18000
# Node ID 0325ff29401e518a70a67f2fcab11ebabfb6e25f
# Parent  098dfb2b759606dc338e63de9380d5173db27224
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 -r 098dfb2b7596 -r 0325ff29401e mercurial/commands.py
--- a/mercurial/commands.py	Tue Oct 12 23:33:43 2010 -0500
+++ 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]...')),
diff -r 098dfb2b7596 -r 0325ff29401e tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t	Tue Oct 12 23:33:43 2010 -0500
+++ 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: 


More information about the Mercurial-devel mailing list