D4471: state: use our CBOR module

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Sep 5 08:23:34 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5bfab9400daf: state: use our CBOR module (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4471?vs=10768&id=10788

REVISION DETAIL
  https://phab.mercurial-scm.org/D4471

AFFECTED FILES
  mercurial/state.py

CHANGE DETAILS

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -19,12 +19,13 @@
 
 from __future__ import absolute_import
 
-from .thirdparty import cbor
-
 from . import (
     error,
     util,
 )
+from .utils import (
+    cborutil,
+)
 
 class cmdstate(object):
     """a wrapper class to store the state of commands like `rebase`, `graft`,
@@ -62,7 +63,8 @@
 
         with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp:
             fp.write('%d\n' % version)
-            cbor.dump(data, fp, canonical=True)
+            for chunk in cborutil.streamencode(data):
+                fp.write(chunk)
 
     def _read(self):
         """reads the state file and returns a dictionary which contain
@@ -73,7 +75,8 @@
             except ValueError:
                 raise error.CorruptedState("unknown version of state file"
                                            " found")
-            return cbor.load(fp)
+
+            return cborutil.decodeall(fp.read())[0]
 
     def delete(self):
         """drop the state file if exists"""



To: indygreg, #hg-reviewers, pulkit
Cc: mercurial-devel


More information about the Mercurial-devel mailing list