templatefilters.json: call functions
The "changeset" template from hgweb is using a lambda in the
"diffsummary" key. In preparation for enabling JSON output from hgweb,
teach the json filter how to call functions.
--- a/mercurial/templatefilters.py Thu Jan 01 16:47:14 2015 -0600
+++ b/mercurial/templatefilters.py Wed Dec 31 11:22:17 2014 -0800
@@ -208,6 +208,8 @@
for i in obj:
out.append(json(i))
return '[' + ', '.join(out) + ']'
+ elif util.safehasattr(obj, '__call__'):
+ return json(obj())
else:
raise TypeError('cannot encode type %s' % obj.__class__.__name__)