comparison mercurial/manifest.py @ 22786:079a0ed5ee4a

manifest: move manifest parsing to module-level We'll need this in the sharded manifest hashing routine, and I need to tweak it anyway, so make it module-level now.
author Augie Fackler <raf@durin42.com>
date Thu, 25 Sep 2014 14:13:31 -0400
parents 65ec6c5c0fb3
children 4a13849ca359
comparison
equal deleted inserted replaced
22785:abc44fcc9c57 22786:079a0ed5ee4a
68 68
69 deltatext = "".join(struct.pack(">lll", start, end, len(content)) 69 deltatext = "".join(struct.pack(">lll", start, end, len(content))
70 + content for start, end, content in x) 70 + content for start, end, content in x)
71 return deltatext, newaddlist 71 return deltatext, newaddlist
72 72
73 def _parse(lines):
74 mfdict = manifestdict()
75 parsers.parse_manifest(mfdict, mfdict._flags, lines)
76 return mfdict
73 77
74 class manifest(revlog.revlog): 78 class manifest(revlog.revlog):
75 def __init__(self, opener): 79 def __init__(self, opener):
76 # we expect to deal with not more than four revs at a time, 80 # we expect to deal with not more than four revs at a time,
77 # during a commit --amend 81 # during a commit --amend
78 self._mancache = util.lrucachedict(4) 82 self._mancache = util.lrucachedict(4)
79 revlog.revlog.__init__(self, opener, "00manifest.i") 83 revlog.revlog.__init__(self, opener, "00manifest.i")
80 84
81 def parse(self, lines):
82 mfdict = manifestdict()
83 parsers.parse_manifest(mfdict, mfdict._flags, lines)
84 return mfdict
85
86 def readdelta(self, node): 85 def readdelta(self, node):
87 r = self.rev(node) 86 r = self.rev(node)
88 return self.parse(mdiff.patchtext(self.revdiff(self.deltaparent(r), r))) 87 return _parse(mdiff.patchtext(self.revdiff(self.deltaparent(r), r)))
89 88
90 def readfast(self, node): 89 def readfast(self, node):
91 '''use the faster of readdelta or read''' 90 '''use the faster of readdelta or read'''
92 r = self.rev(node) 91 r = self.rev(node)
93 deltaparent = self.deltaparent(r) 92 deltaparent = self.deltaparent(r)
100 return manifestdict() # don't upset local cache 99 return manifestdict() # don't upset local cache
101 if node in self._mancache: 100 if node in self._mancache:
102 return self._mancache[node][0] 101 return self._mancache[node][0]
103 text = self.revision(node) 102 text = self.revision(node)
104 arraytext = array.array('c', text) 103 arraytext = array.array('c', text)
105 mapping = self.parse(text) 104 mapping = _parse(text)
106 self._mancache[node] = (mapping, arraytext) 105 self._mancache[node] = (mapping, arraytext)
107 return mapping 106 return mapping
108 107
109 def _search(self, m, s, lo=0, hi=None): 108 def _search(self, m, s, lo=0, hi=None):
110 '''return a tuple (start, end) that says where to find s within m. 109 '''return a tuple (start, end) that says where to find s within m.