[PATCH 0 of 5] Interactive editor merge with markers

David Champion dgc at uchicago.edu
Mon May 10 18:07:05 CDT 2010


* On 10 May 2010, Matt Mackall wrote: 
> 
> Ok, I've merged all of this except the actually stanza for
> mergetools.hgrc which adds the new editor tool. We should try to figure
> out if we can come up with something a little cleaner/more portable here
> for finding an appropriate editor.

How about this? executable, args, and premerge are now implied, but can
be overridden.  Here's the minimal mergetools.hgrc entry for it.  (Not
sure what your version looks like just now.)

[merge-tools]
# Fall back on ui.editor on the premerged local file
internal:editor.check = conflicts, prompt
internal:editor.priority = -99
internal:editor.gui = False


# HG changeset patch
# User David Champion <dgc at uchicago.edu>
# Date 1273531190 18000
# Node ID 4815dc594c92c226eed62d8329de854907a64bcc
# Parent  05bfadea9d45381c097507dfd1ad6339e438de2a
merge: "internal:editor" tool always uses ui.geteditor()

If a tool name is "internal:editor", executable defaults to
ui.geteditor(), args defaults to '$local', and premerge defaults to
'keep'.

diff -r 05bfadea9d45 -r 4815dc594c92 doc/hgrc.5.txt
--- a/doc/hgrc.5.txt	Mon May 10 11:04:56 2010 -0500
+++ b/doc/hgrc.5.txt	Mon May 10 17:39:50 2010 -0500
@@ -804,6 +804,8 @@
     The conflict resolution program to use during a manual merge.
     There are some internal tools available:
 
+    ``internal:editor``
+        use your editor on the local version
     ``internal:local``
         keep the local version
     ``internal:other``
diff -r 05bfadea9d45 -r 4815dc594c92 mercurial/filemerge.py
--- a/mercurial/filemerge.py	Mon May 10 11:04:56 2010 -0500
+++ b/mercurial/filemerge.py	Mon May 10 17:39:50 2010 -0500
@@ -20,7 +20,7 @@
     return ui.configlist("merge-tools", tool + "." + part, default)
 
 _internal = ['internal:' + s
-             for s in 'fail local other merge prompt dump'.split()]
+             for s in 'fail local other merge prompt dump editor'.split()]
 
 def _findtool(ui, tool):
     if tool in _internal:
@@ -180,9 +180,15 @@
 
     # do we attempt to simplemerge first?
     try:
-        premerge = _toolbool(ui, tool, "premerge", not (binary or symlink))
+        if tool == 'internal:editor':
+            premerge = _toolbool(ui, tool, "premerge", 'keep')
+        else:
+            premerge = _toolbool(ui, tool, "premerge", not (binary or symlink))
     except error.ConfigError:
-        premerge = _toolstr(ui, tool, "premerge").lower()
+        if tool == 'internal:editor':
+            premerge = _toolstr(ui, tool, "premerge", 'keep').lower()
+        else:
+            premerge = _toolstr(ui, tool, "premerge").lower()
         valid = 'keep'.split()
         if premerge not in valid:
             _valid = ', '.join(["'" + v + "'" for v in valid])
@@ -218,7 +224,11 @@
         repo.wwrite(fd + ".base", fca.data(), fca.flags())
         return 1 # unresolved
     else:
-        args = _toolstr(ui, tool, "args", '$local $base $other')
+        if tool == "internal:editor":
+            toolpath = ui.geteditor()
+            args = _toolstr(ui, tool, "args", '$local')
+        else:
+            args = _toolstr(ui, tool, "args", '$local $base $other')
         if "$output" in args:
             out, a = a, back # read input from backup, write to original
         replace = dict(local=a, base=b, other=c, output=out)



More information about the Mercurial-devel mailing list