templatefilters.json: stabilize output
authorGregory Szorc <gregory.szorc@gmail.com>
Wed, 31 Dec 2014 13:48:55 -0800
changeset 23708 a9f826c3eaf9
parent 23707 ae5447de4c11
child 23709 33e5431684c0
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.
mercurial/templatefilters.py
--- 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) + '}'