Mercurial > public > mercurial-scm > hg-stable
diff mercurial/filemerge.py @ 40528:86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
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.
Differential Revision: https://phab.mercurial-scm.org/D5094
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Sat, 13 Oct 2018 07:49:20 -0700 |
parents | bc0eb1dc6aae |
children | 876494fd967d |
line wrap: on
line diff
--- a/mercurial/filemerge.py Fri Oct 26 21:46:37 2018 +0900 +++ b/mercurial/filemerge.py Sat Oct 13 07:49:20 2018 -0700 @@ -13,7 +13,11 @@ import shutil from .i18n import _ -from .node import nullid, short +from .node import ( + hex, + nullid, + short, +) from . import ( encoding, @@ -27,6 +31,7 @@ tagmerge, templatekw, templater, + templateutil, util, ) @@ -536,6 +541,44 @@ raise error.InMemoryMergeConflictsError('in-memory merge does not support ' 'external merge tools') +def _describemerge(ui, repo, mynode, fcl, fcb, fco, env, toolpath, args): + tmpl = ui.config('ui', 'pre-merge-tool-output-template') + if not tmpl: + return + + mappingdict = templateutil.mappingdict + props = {'ctx': fcl.changectx(), + 'node': hex(mynode), + 'path': fcl.path(), + 'local': mappingdict({'ctx': fcl.changectx(), + 'fctx': fcl, + 'node': hex(mynode), + 'name': _('local'), + 'islink': 'l' in fcl.flags(), + 'label': env['HG_MY_LABEL']}), + 'base': mappingdict({'ctx': fcb.changectx(), + 'fctx': fcb, + 'name': _('base'), + 'islink': 'l' in fcb.flags(), + 'label': env['HG_BASE_LABEL']}), + 'other': mappingdict({'ctx': fco.changectx(), + 'fctx': fco, + 'name': _('other'), + 'islink': 'l' in fco.flags(), + 'label': env['HG_OTHER_LABEL']}), + 'toolpath': toolpath, + 'toolargs': args} + + # TODO: make all of this something that can be specified on a per-tool basis + tmpl = templater.unquotestring(tmpl) + + # Not using cmdutil.rendertemplate here since it causes errors importing + # things for us to import cmdutil. + tres = formatter.templateresources(ui, repo) + t = formatter.maketemplater(ui, tmpl, defaults=templatekw.keywords, + resources=tres) + ui.status(t.renderdefault(props)) + 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 +627,7 @@ if scriptfn is None: cmd = toolpath + ' ' + args repo.ui.debug('launching merge tool: %s\n' % cmd) + _describemerge(ui, repo, mynode, fcd, fca, fco, env, toolpath, args) r = ui.system(cmd, cwd=repo.root, environ=env, blockedtag='mergetool') else: