--- a/mercurial/templater.py Mon Apr 03 22:54:06 2017 +0900
+++ b/mercurial/templater.py Sat Apr 08 23:33:32 2017 +0900
@@ -284,6 +284,18 @@
return context._load(exp[1])
raise error.ParseError(_("expected template specifier"))
+def findsymbolicname(arg):
+ """Find symbolic name for the given compiled expression; returns None
+ if nothing found reliably"""
+ while True:
+ func, data = arg
+ if func is runsymbol:
+ return data
+ elif func is runfilter:
+ arg = data[0]
+ else:
+ return None
+
def evalfuncarg(context, mapping, arg):
func, data = arg
# func() may return string, generator of strings or arbitrary object such
@@ -387,12 +399,13 @@
try:
return filt(thing)
except (ValueError, AttributeError, TypeError):
- if isinstance(arg[1], tuple):
- dt = arg[1][1]
+ sym = findsymbolicname(arg)
+ if sym:
+ msg = (_("template filter '%s' is not compatible with keyword '%s'")
+ % (filt.func_name, sym))
else:
- dt = arg[1]
- raise error.Abort(_("template filter '%s' is not compatible with "
- "keyword '%s'") % (filt.func_name, dt))
+ msg = _("incompatible use of template filter '%s'") % filt.func_name
+ raise error.Abort(msg)
def buildmap(exp, context):
func, data = compileexp(exp[1], context, methods)