state: set canonical=True to write deterministically
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 18 May 2018 16:34:19 +0530
changeset 38105 18c6d8b565bf
parent 38104 36a5a1239a15
child 38106 a0e4d654bceb
state: set canonical=True to write deterministically Passing canonical=True to cbor.dump() will help in writing the data deterministically. This will sort all the sets and dicts before writing to the file. Thanks indygreg for recommending to use it. Differential Revision: https://phab.mercurial-scm.org/D3578
mercurial/state.py
--- a/mercurial/state.py	Wed Mar 28 16:31:16 2018 +0530
+++ b/mercurial/state.py	Fri May 18 16:34:19 2018 +0530
@@ -57,7 +57,7 @@
         we use third-party library cbor to serialize data to write in the file.
         """
         with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp:
-            cbor.dump(self.opts, fp)
+            cbor.dump(self.opts, fp, canonical=True)
 
     def _read(self):
         """reads the state file and returns a dictionary which contain