Bug 1293868 - Write mozinfo.json deterministically; r?glandium draft
authorGregory Szorc <gps@mozilla.com>
Tue, 09 Aug 2016 19:11:54 -0700
changeset 400314 8e3cac67905e744e6e5bd7104be09ca50bfa52df
parent 400313 2ed7e61b988d2466a61528f66050596ef272ebda
child 528187 6f11ef6988fbc19649fc780a7875cbaf8fe093db
push id26128
push userbmo:gps@mozilla.com
push dateFri, 12 Aug 2016 23:34:07 +0000
reviewersglandium
bugs1293868
milestone51.0a1
Bug 1293868 - Write mozinfo.json deterministically; r?glandium And with indentation so it is easier for humans to read. MozReview-Commit-ID: Kkd6vmfLNUf
python/mozbuild/mozbuild/mozinfo.py
--- a/python/mozbuild/mozbuild/mozinfo.py
+++ b/python/mozbuild/mozbuild/mozinfo.py
@@ -150,12 +150,11 @@ def write_mozinfo(file, config, env=os.e
     """Write JSON data about the configuration specified in config and an
     environment variable dict to |file|, which may be a filename or file-like
     object.
     See build_dict for information about what  environment variables are used,
     and what keys are produced.
     """
     build_conf = build_dict(config, env)
     if isinstance(file, basestring):
-        with open(file, "w") as f:
-            json.dump(build_conf, f)
-    else:
-        json.dump(build_conf, file)
+        file = open(file, 'wb')
+
+    json.dump(build_conf, file, sort_keys=True, indent=4)