comparison mercurial/manifest.py @ 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 d9832a12a06e
comparison
equal deleted inserted replaced
24780:4ea521b3c554 24781:055b3cbe6c57
446 self._dir = dir 446 self._dir = dir
447 self._dirs = {} 447 self._dirs = {}
448 # Using _lazymanifest here is a little slower than plain old dicts 448 # Using _lazymanifest here is a little slower than plain old dicts
449 self._files = {} 449 self._files = {}
450 self._flags = {} 450 self._flags = {}
451 for f, n, fl in _parse(text): 451 self.parse(text)
452 self[f] = n
453 if fl:
454 self.setflag(f, fl)
455 452
456 def _subpath(self, path): 453 def _subpath(self, path):
457 return self._dir + path 454 return self._dir + path
458 455
459 def __len__(self): 456 def __len__(self):
737 fl2 = t2._flags.get(fn, '') 734 fl2 = t2._flags.get(fn, '')
738 result[t2._subpath(fn)] = ((None, ''), (n2, fl2)) 735 result[t2._subpath(fn)] = ((None, ''), (n2, fl2))
739 736
740 _diff(self, m2) 737 _diff(self, m2)
741 return result 738 return result
739
740 def parse(self, text):
741 for f, n, fl in _parse(text):
742 self[f] = n
743 if fl:
744 self.setflag(f, fl)
742 745
743 def text(self, usemanifestv2=False): 746 def text(self, usemanifestv2=False):
744 """Get the full data of this manifest as a bytestring.""" 747 """Get the full data of this manifest as a bytestring."""
745 flags = self.flags 748 flags = self.flags
746 return _text(((f, self[f], flags(f)) for f in self.keys()), 749 return _text(((f, self[f], flags(f)) for f in self.keys()),