changeset 24781:055b3cbe6c57

treemanifest: extract parse method from constructor When we start to lazily load submanifests, it will be useful to be able to create an treemanifest instance before manifest data gets parsed into it. To prepare for this, extract the parsing code from treemanifest's constructor to a separate method.
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 12 Apr 2015 23:01:18 -0700
parents 4ea521b3c554
children 4906dc0e038c
files mercurial/manifest.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/manifest.py	Sun Apr 12 14:37:55 2015 -0700
+++ b/mercurial/manifest.py	Sun Apr 12 23:01:18 2015 -0700
@@ -448,10 +448,7 @@
         # Using _lazymanifest here is a little slower than plain old dicts
         self._files = {}
         self._flags = {}
-        for f, n, fl in _parse(text):
-            self[f] = n
-            if fl:
-                self.setflag(f, fl)
+        self.parse(text)
 
     def _subpath(self, path):
         return self._dir + path
@@ -740,6 +737,12 @@
         _diff(self, m2)
         return result
 
+    def parse(self, text):
+        for f, n, fl in _parse(text):
+            self[f] = n
+            if fl:
+                self.setflag(f, fl)
+
     def text(self, usemanifestv2=False):
         """Get the full data of this manifest as a bytestring."""
         flags = self.flags