Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 13264:8439526fb407
revlog/parseindex: no need to pass the file around
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sat, 15 Jan 2011 15:04:58 +0100 |
parents | 3b616dfa4b17 |
children | 04b302ce2781 |
comparison
equal
deleted
inserted
replaced
13263:c45b5faa6213 | 13264:8439526fb407 |
---|---|
124 | 124 |
125 class revlogoldio(object): | 125 class revlogoldio(object): |
126 def __init__(self): | 126 def __init__(self): |
127 self.size = struct.calcsize(indexformatv0) | 127 self.size = struct.calcsize(indexformatv0) |
128 | 128 |
129 def parseindex(self, fp, data, inline): | 129 def parseindex(self, data, inline): |
130 s = self.size | 130 s = self.size |
131 index = [] | 131 index = [] |
132 nodemap = {nullid: nullrev} | 132 nodemap = {nullid: nullrev} |
133 n = off = 0 | 133 n = off = 0 |
134 l = len(data) | 134 l = len(data) |
168 | 168 |
169 class revlogio(object): | 169 class revlogio(object): |
170 def __init__(self): | 170 def __init__(self): |
171 self.size = struct.calcsize(indexformatng) | 171 self.size = struct.calcsize(indexformatng) |
172 | 172 |
173 def parseindex(self, fp, data, inline): | 173 def parseindex(self, data, inline): |
174 # call the C implementation to parse the index data | 174 # call the C implementation to parse the index data |
175 index, cache = parsers.parse_index2(data, inline) | 175 index, cache = parsers.parse_index2(data, inline) |
176 return index, None, cache | 176 return index, None, cache |
177 | 177 |
178 def packentry(self, entry, node, version, rev): | 178 def packentry(self, entry, node, version, rev): |
262 self._io = revlogio() | 262 self._io = revlogio() |
263 if self.version == REVLOGV0: | 263 if self.version == REVLOGV0: |
264 self._io = revlogoldio() | 264 self._io = revlogoldio() |
265 if i: | 265 if i: |
266 try: | 266 try: |
267 d = self._io.parseindex(f, i, self._inline) | 267 d = self._io.parseindex(i, self._inline) |
268 except (ValueError, IndexError): | 268 except (ValueError, IndexError): |
269 raise RevlogError(_("index %s is corrupted") % (self.indexfile)) | 269 raise RevlogError(_("index %s is corrupted") % (self.indexfile)) |
270 self.index, n, self._chunkcache = d | 270 self.index, n, self._chunkcache = d |
271 if n: | 271 if n: |
272 self.nodemap = n | 272 self.nodemap = n |