changeset 24224:d71837d06597

manifest: do parsing inside manifestdict contstructor This shape to the code will make using a C implementation of the manifest storage easier.
author Augie Fackler <augie@google.com>
date Sat, 07 Mar 2015 11:43:12 -0500
parents b4df0d0c49e7
children 3e5c4af69808
files mercurial/manifest.py
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/manifest.py	Sat Mar 07 11:42:05 2015 -0500
+++ b/mercurial/manifest.py	Sat Mar 07 11:43:12 2015 -0500
@@ -20,17 +20,18 @@
         else:
             mfdict[f] = bin(n)
 
-def _parse(lines):
-    mfdict = manifestdict()
+def _parse(lines, mfdict, flags):
     try:
-        parsers.parse_manifest(mfdict, mfdict._flags, lines)
+        parsers.parse_manifest(mfdict, flags, lines)
     except AttributeError:
-        _parsemanifest(mfdict, mfdict._flags, lines)
+        _parsemanifest(mfdict, flags, lines)
     return mfdict
 
 class manifestdict(dict):
-    def __init__(self):
+    def __init__(self, data=''):
         self._flags = {}
+        _parse(data, self, self._flags)
+
     def __setitem__(self, k, v):
         assert v is not None
         dict.__setitem__(self, k, v)
@@ -250,7 +251,8 @@
 
     def readdelta(self, node):
         r = self.rev(node)
-        return _parse(mdiff.patchtext(self.revdiff(self.deltaparent(r), r)))
+        d = mdiff.patchtext(self.revdiff(self.deltaparent(r), r))
+        return manifestdict(d)
 
     def readfast(self, node):
         '''use the faster of readdelta or read'''
@@ -267,7 +269,7 @@
             return self._mancache[node][0]
         text = self.revision(node)
         arraytext = array.array('c', text)
-        m = _parse(text)
+        m = manifestdict(text)
         self._mancache[node] = (m, arraytext)
         return m