comparison mercurial/revlog.py @ 8558:5726bb290bfe

revlog: fix reading of larger revlog indices on Windows
author Matt Mackall <mpm@selenic.com>
date Sat, 23 May 2009 11:53:23 -0500
parents f9a80054dd3c
children 6f21613d25a2
comparison
equal deleted inserted replaced
8557:67f76a4463ef 8558:5726bb290bfe
320 def parseindex(self, fp, data, inline): 320 def parseindex(self, fp, data, inline):
321 s = self.size 321 s = self.size
322 index = [] 322 index = []
323 nodemap = {nullid: nullrev} 323 nodemap = {nullid: nullrev}
324 n = off = 0 324 n = off = 0
325 if len(data) < _prereadsize: 325 if len(data) == _prereadsize:
326 data += fp.read() # read the rest 326 data += fp.read() # read the rest
327 l = len(data) 327 l = len(data)
328 while off + s <= l: 328 while off + s <= l:
329 cur = data[off:off + s] 329 cur = data[off:off + s]
330 off += s 330 off += s
360 class revlogio(object): 360 class revlogio(object):
361 def __init__(self): 361 def __init__(self):
362 self.size = struct.calcsize(indexformatng) 362 self.size = struct.calcsize(indexformatng)
363 363
364 def parseindex(self, fp, data, inline): 364 def parseindex(self, fp, data, inline):
365 try: 365 if len(data) == _prereadsize:
366 size = len(data) 366 if util.openhardlinks() and not inline:
367 if size == _prereadsize: 367 # big index, let's parse it on demand
368 size = util.fstat(fp).st_size 368 parser = lazyparser(fp, size)
369 except AttributeError: 369 index = lazyindex(parser)
370 size = 0 370 nodemap = lazymap(parser)
371 371 e = list(index[0])
372 if util.openhardlinks() and not inline and size > _prereadsize: 372 type = gettype(e[0])
373 # big index, let's parse it on demand 373 e[0] = offset_type(0, type)
374 parser = lazyparser(fp, size) 374 index[0] = e
375 index = lazyindex(parser) 375 return index, nodemap, None
376 nodemap = lazymap(parser) 376 else:
377 e = list(index[0]) 377 data += fp.read()
378 type = gettype(e[0])
379 e[0] = offset_type(0, type)
380 index[0] = e
381 return index, nodemap, None
382 378
383 # call the C implementation to parse the index data 379 # call the C implementation to parse the index data
384 index, nodemap, cache = parsers.parse_index(data, inline) 380 index, nodemap, cache = parsers.parse_index(data, inline)
385 return index, nodemap, cache 381 return index, nodemap, cache
386 382