templatefilters.json: stabilize output
The json filter was previously iterating over keys in an object in an
undefined order. Let's throw a sorted() in there so output is
consistent.
It's somewhat frightening that there are no tests for the json filter.
Subsequent commits will add them, so we pass on the opportunity to add
them here.
--- a/mercurial/templatefilters.py Wed Dec 31 11:22:17 2014 -0800
+++ b/mercurial/templatefilters.py Wed Dec 31 13:48:55 2014 -0800
@@ -199,7 +199,7 @@
return '"%s"' % jsonescape(obj)
elif util.safehasattr(obj, 'keys'):
out = []
- for k, v in obj.iteritems():
+ for k, v in sorted(obj.iteritems()):
s = '%s: %s' % (json(k), json(v))
out.append(s)
return '{' + ', '.join(out) + '}'