Show More
@@ -31,6 +31,8 b' REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDAT' | |||
|
31 | 31 | REVLOG_DEFAULT_FORMAT = REVLOGNG |
|
32 | 32 | REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS |
|
33 | 33 | |
|
34 | _prereadsize = 1048576 | |
|
35 | ||
|
34 | 36 | RevlogError = error.RevlogError |
|
35 | 37 | LookupError = error.LookupError |
|
36 | 38 | |
@@ -315,12 +317,13 b' class revlogoldio(object):' | |||
|
315 | 317 | def __init__(self): |
|
316 | 318 | self.size = struct.calcsize(indexformatv0) |
|
317 | 319 | |
|
318 | def parseindex(self, fp, inline): | |
|
320 | def parseindex(self, fp, data, inline): | |
|
319 | 321 | s = self.size |
|
320 | 322 | index = [] |
|
321 | 323 | nodemap = {nullid: nullrev} |
|
322 | 324 | n = off = 0 |
|
323 |
data |
|
|
325 | if len(data) < _prereadsize: | |
|
326 | data += fp.read() # read the rest | |
|
324 | 327 | l = len(data) |
|
325 | 328 | while off + s <= l: |
|
326 | 329 | cur = data[off:off + s] |
@@ -358,13 +361,15 b' class revlogio(object):' | |||
|
358 | 361 | def __init__(self): |
|
359 | 362 | self.size = struct.calcsize(indexformatng) |
|
360 | 363 | |
|
361 | def parseindex(self, fp, inline): | |
|
364 | def parseindex(self, fp, data, inline): | |
|
362 | 365 | try: |
|
366 | size = len(data) | |
|
367 | if size == _prereadsize: | |
|
363 | 368 | size = util.fstat(fp).st_size |
|
364 | 369 | except AttributeError: |
|
365 | 370 | size = 0 |
|
366 | 371 | |
|
367 |
if util.openhardlinks() and not inline and size > |
|
|
372 | if util.openhardlinks() and not inline and size > _prereadsize: | |
|
368 | 373 | # big index, let's parse it on demand |
|
369 | 374 | parser = lazyparser(fp, size) |
|
370 | 375 | index = lazyindex(parser) |
@@ -375,7 +380,6 b' class revlogio(object):' | |||
|
375 | 380 | index[0] = e |
|
376 | 381 | return index, nodemap, None |
|
377 | 382 | |
|
378 | data = fp.read() | |
|
379 | 383 | # call the C implementation to parse the index data |
|
380 | 384 | index, nodemap, cache = parsers.parse_index(data, inline) |
|
381 | 385 | return index, nodemap, cache |
@@ -432,13 +436,12 b' class revlog(object):' | |||
|
432 | 436 | if v & REVLOGNG: |
|
433 | 437 | v |= REVLOGNGINLINEDATA |
|
434 | 438 | |
|
435 |
i = |
|
|
439 | i = '' | |
|
436 | 440 | try: |
|
437 | 441 | f = self.opener(self.indexfile) |
|
438 |
i = f.read( |
|
|
439 | f.seek(0) | |
|
442 | i = f.read(_prereadsize) | |
|
440 | 443 | if len(i) > 0: |
|
441 | v = struct.unpack(versionformat, i)[0] | |
|
444 | v = struct.unpack(versionformat, i[:4])[0] | |
|
442 | 445 | except IOError, inst: |
|
443 | 446 | if inst.errno != errno.ENOENT: |
|
444 | 447 | raise |
@@ -462,7 +465,7 b' class revlog(object):' | |||
|
462 | 465 | self._io = revlogoldio() |
|
463 | 466 | if i: |
|
464 | 467 | try: |
|
465 | d = self._io.parseindex(f, self._inline) | |
|
468 | d = self._io.parseindex(f, i, self._inline) | |
|
466 | 469 | except (ValueError, IndexError), e: |
|
467 | 470 | raise RevlogError(_("index %s is corrupted") % (self.indexfile)) |
|
468 | 471 | self.index, self.nodemap, self._chunkcache = d |
General Comments 0
You need to be logged in to leave comments.
Login now