# HG changeset patch # User Gregory Szorc # Date 1420053737 28800 # Node ID ae5447de4c1100661fdff69397f70358394da512 # Parent 3314664606e63e0ae263b71f5210e8153291efe8 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. diff -r 3314664606e6 -r ae5447de4c11 mercurial/templatefilters.py --- 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__)