comparison mercurial/revlog.py @ 13265:04b302ce2781

revlog: always add the magic nullid/nullrev entry in parseindex
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 15 Jan 2011 13:02:19 +0100
parents 8439526fb407
children a5db81b5d3e9
comparison
equal deleted inserted replaced
13264:8439526fb407 13265:04b302ce2781
141 nodemap.get(e[4], nullrev), nodemap.get(e[5], nullrev), e[6]) 141 nodemap.get(e[4], nullrev), nodemap.get(e[5], nullrev), e[6])
142 index.append(e2) 142 index.append(e2)
143 nodemap[e[6]] = n 143 nodemap[e[6]] = n
144 n += 1 144 n += 1
145 145
146 # add the magic null revision at -1
147 index.append((0, 0, 0, -1, -1, -1, -1, nullid))
148
146 return index, nodemap, None 149 return index, nodemap, None
147 150
148 def packentry(self, entry, node, version, rev): 151 def packentry(self, entry, node, version, rev):
149 if gettype(entry[0]): 152 if gettype(entry[0]):
150 raise RevlogError(_("index entry flags need RevlogNG")) 153 raise RevlogError(_("index entry flags need RevlogNG"))
260 % (self.indexfile, fmt)) 263 % (self.indexfile, fmt))
261 264
262 self._io = revlogio() 265 self._io = revlogio()
263 if self.version == REVLOGV0: 266 if self.version == REVLOGV0:
264 self._io = revlogoldio() 267 self._io = revlogoldio()
265 if i: 268 try:
266 try: 269 d = self._io.parseindex(i, self._inline)
267 d = self._io.parseindex(i, self._inline) 270 except (ValueError, IndexError):
268 except (ValueError, IndexError): 271 raise RevlogError(_("index %s is corrupted") % (self.indexfile))
269 raise RevlogError(_("index %s is corrupted") % (self.indexfile)) 272 self.index, n, self._chunkcache = d
270 self.index, n, self._chunkcache = d 273 if n:
271 if n: 274 self.nodemap = n
272 self.nodemap = n 275 if not self._chunkcache:
273 if not self._chunkcache: 276 self._chunkclear()
274 self._chunkclear()
275
276 # add the magic null revision at -1 (if it hasn't been done already)
277 if self.index == [] or self.index[-1][7] != nullid:
278 self.index.append((0, 0, 0, -1, -1, -1, -1, nullid))
279 277
280 @util.propertycache 278 @util.propertycache
281 def nodemap(self): 279 def nodemap(self):
282 n = {nullid: nullrev} 280 n = {nullid: nullrev}
283 i = self.index 281 i = self.index