--- a/mercurial/filemerge.py Fri Feb 02 23:20:55 2018 -0500
+++ b/mercurial/filemerge.py Wed Jan 17 17:35:05 2018 -0800
@@ -513,6 +513,11 @@
b, c = _maketempfiles(repo, fco, fca)
try:
out = ""
+ mylabel, otherlabel = labels[:2]
+ if len(labels) >= 3:
+ baselabel = labels[2]
+ else:
+ baselabel = 'base'
env = {'HG_FILE': fcd.path(),
'HG_MY_NODE': short(mynode),
'HG_OTHER_NODE': str(fco.changectx()),
@@ -520,6 +525,9 @@
'HG_MY_ISLINK': 'l' in fcd.flags(),
'HG_OTHER_ISLINK': 'l' in fco.flags(),
'HG_BASE_ISLINK': 'l' in fca.flags(),
+ 'HG_MY_LABEL': mylabel,
+ 'HG_OTHER_LABEL': otherlabel,
+ 'HG_BASE_LABEL': baselabel,
}
ui = repo.ui
@@ -528,7 +536,9 @@
# read input from backup, write to original
out = a
a = repo.wvfs.join(back.path())
- replace = {'local': a, 'base': b, 'other': c, 'output': out}
+ replace = {'local': a, 'base': b, 'other': c, 'output': out,
+ 'labellocal': mylabel, 'labelother': otherlabel,
+ 'labelbase': baselabel}
args = util.interpolate(br'\$', replace, args,
lambda s: util.shellquote(util.localpath(s)))
cmd = toolpath + ' ' + args
@@ -566,7 +576,7 @@
_defaultconflictlabels = ['local', 'other']
-def _formatlabels(repo, fcd, fco, fca, labels):
+def _formatlabels(repo, fcd, fco, fca, labels, tool=None):
"""Formats the given labels using the conflict marker template.
Returns a list of formatted labels.
@@ -577,6 +587,8 @@
ui = repo.ui
template = ui.config('ui', 'mergemarkertemplate')
+ if tool is not None:
+ template = _toolstr(ui, tool, 'mergemarkertemplate', template)
template = templater.unquotestring(template)
tres = formatter.templateresources(ui, repo)
tmpl = formatter.maketemplater(ui, template, defaults=templatekw.keywords,
@@ -706,6 +718,7 @@
mergetype = func.mergetype
onfailure = func.onfailure
precheck = func.precheck
+ isexternal = False
else:
if wctx.isinmemory():
func = _xmergeimm
@@ -714,6 +727,7 @@
mergetype = fullmerge
onfailure = _("merging %s failed!\n")
precheck = None
+ isexternal = True
toolconf = tool, toolpath, binary, symlink
@@ -743,19 +757,42 @@
files = (None, None, None, back)
r = 1
try:
- markerstyle = ui.config('ui', 'mergemarkers')
+ internalmarkerstyle = ui.config('ui', 'mergemarkers')
+ if isexternal:
+ markerstyle = _toolstr(ui, tool, 'mergemarkers')
+ else:
+ markerstyle = internalmarkerstyle
+
if not labels:
labels = _defaultconflictlabels
+ formattedlabels = labels
if markerstyle != 'basic':
- labels = _formatlabels(repo, fcd, fco, fca, labels)
+ formattedlabels = _formatlabels(repo, fcd, fco, fca, labels,
+ tool=tool)
if premerge and mergetype == fullmerge:
- r = _premerge(repo, fcd, fco, fca, toolconf, files, labels=labels)
+ # conflict markers generated by premerge will use 'detailed'
+ # settings if either ui.mergemarkers or the tool's mergemarkers
+ # setting is 'detailed'. This way tools can have basic labels in
+ # space-constrained areas of the UI, but still get full information
+ # in conflict markers if premerge is 'keep' or 'keep-merge3'.
+ premergelabels = labels
+ labeltool = None
+ if markerstyle != 'basic':
+ # respect 'tool's mergemarkertemplate (which defaults to
+ # ui.mergemarkertemplate)
+ labeltool = tool
+ if internalmarkerstyle != 'basic' or markerstyle != 'basic':
+ premergelabels = _formatlabels(repo, fcd, fco, fca,
+ premergelabels, tool=labeltool)
+
+ r = _premerge(repo, fcd, fco, fca, toolconf, files,
+ labels=premergelabels)
# complete if premerge successful (r is 0)
return not r, r, False
needcheck, r, deleted = func(repo, mynode, orig, fcd, fco, fca,
- toolconf, files, labels=labels)
+ toolconf, files, labels=formattedlabels)
if needcheck:
r = _check(repo, r, ui, tool, fcd, files)