spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It is a common complaint that a user will be running some operation (histedit,
  rebase, evolve, etc.), get into a merge-conflict situation, and not understand
  what they are seeing - it is possible that the merge tool is configured to
  display the hash, but it's difficult for most merge tools to display a good
  snippet of the description.
  
  In the worst case, configuring this template will lead to output that is
  immediately covered by a terminal application, maybe the user can hit ctrl-z 
to
  see it. In the common case, the output will be in a terminal window and a GUI
  program will start, and it should be possible to view both the terminal and 
the
  GUI program at the same time.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -536,6 +536,27 @@
     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()}
+
+    # 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 +605,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:



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

Reply via email to