spectral updated this revision to Diff 12106.
Herald added a subscriber: mjpieters.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5094?vs=12105&id=12106

REVISION DETAIL
  https://phab.mercurial-scm.org/D5094

AFFECTED FILES
  mercurial/configitems.py
  mercurial/filemerge.py
  tests/test-merge-tools.t

CHANGE DETAILS

diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -1942,6 +1942,25 @@
   0000: 00 01 02 03                                     |....|
   $ hg merge --abort -q
 
+Check that the extra information is printed correctly
+
+  $ hg merge 9 \
+  >   --config merge-tools.testecho.executable='/bin/echo' \
+  >   --config merge-tools.testecho.args='merge runs here ...' \
+  >   --config merge-tools.testecho.binary=True \
+  >   --config ui.merge=testecho \
+  >   --config 
ui.pre-merge-tool-output-template='\n{label("extmerge.running_merge_tool", 
"Running merge tool for {file} ({toolpath}):")}\n{extmerge_section("local", 
my_label, my_node)}\n{extmerge_section("base", base_label, 
base_node)}\n{extmerge_section("other", other_label, other_node)}\n' \
+  >   --config 'templatealias.extmerge_section(name, label, node)="- 
{pad("{name} ({label})", 20, left=True)}: 
{revset(node)%"{rev}:{shortest(node,8)} {desc|firstline} {separate(tags, 
bookmarks, branch)}"}"'
+  merging b
+  
+  Running merge tool for b (/bin/echo):
+  - local (working copy): 10:2d1f533d add binary file (#2) default
+  -          base (base): -1:00000000  default
+  -    other (merge rev): 9:1e7ad7d7 add binary file (#1) default
+  merge runs here ...
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+
 Check that debugpicktool examines which merge tool is chosen for
 specified file as expected
 
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -536,6 +536,29 @@
     raise error.InMemoryMergeConflictsError('in-memory merge does not support '
                                             'external merge tools')
 
+def _describemerge(ui, repo, env, toolpath, args):
+    template = ui.config('ui', 'pre-merge-tool-output-template')
+    if not template:
+        return
+
+    # Remove HG_ prefix from entries in `env` and lowercase them
+    def sanitizeenv(k):
+        if k.startswith('HG_'):
+            return k[3:].lower()
+        return k
+
+    data = {sanitizeenv(k): v for k, v in env.items()}
+    data['toolpath'] = toolpath
+    data['toolargs'] = args
+
+    # TODO: make all of this something that can be specified on a per-tool 
basis
+    template = templater.unquotestring(template)
+
+    fm = ui.formatter("extmerge", pycompat.byteskwargs({'template': template}))
+    fm.startitem()
+    fm.data(repo=repo, **data)
+    fm.end()
+
 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
     tool, toolpath, binary, symlink, scriptfn = toolconf
     if fcd.isabsent() or fco.isabsent():
@@ -584,6 +607,7 @@
         if scriptfn is None:
             cmd = toolpath + ' ' + args
             repo.ui.debug('launching merge tool: %s\n' % cmd)
+            _describemerge(ui, repo, env, toolpath, args)
             r = ui.system(cmd, cwd=repo.root, environ=env,
                           blockedtag='mergetool')
         else:
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1173,6 +1173,9 @@
 coreconfigitem('ui', 'patch',
     default=None,
 )
+coreconfigitem('ui', 'pre-merge-tool-output-template',
+    default=None,
+)
 coreconfigitem('ui', 'portablefilenames',
     default='warn',
 )



To: spectral, #hg-reviewers
Cc: mjpieters, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to