Patchwork [2,of,2] treemanifest: extract parse method from constructor

login
register
mail settings
Submitter Martin von Zweigbergk
Date April 15, 2015, 8:01 p.m.
Message ID <f739948917053db6732e.1429128073@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8688/
State Accepted
Headers show

Comments

Martin von Zweigbergk - April 15, 2015, 8:01 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1428904878 25200
#      Sun Apr 12 23:01:18 2015 -0700
# Node ID f739948917053db6732e30c62a1089390f4ba06f
# Parent  5f952de4d34db74ec43c07d7f0c893b8976fff73
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.

Patch

diff -r 5f952de4d34d -r f73994891705 mercurial/manifest.py
--- 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