# HG changeset patch # User Gregory Szorc # Date 2014-12-31 21:48:55 # Node ID a9f826c3eaf9dc9743571fd40d3f32b761b0132f # Parent ae5447de4c1100661fdff69397f70358394da512 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. diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -199,7 +199,7 @@ def json(obj): 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) + '}'