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: