comparison mercurial/pure/parsers.py @ 14421:639f26cab2f5

pure parsers: properly detect corrupt index files This new Python code should be equivalent in behavior to the if statement at line 312 of parsers.c. Without this, the pure-python parsers improperly ignore truncated revlogs as created in test-verify.t.
author Augie Fackler <durin42@gmail.com>
date Tue, 24 May 2011 13:30:10 -0500
parents e4bfb9c337f3
children 8d928799dab5
comparison
equal deleted inserted replaced
14420:137b03b5aea1 14421:639f26cab2f5
54 e = _unpack(indexformatng, data[off:off + s]) 54 e = _unpack(indexformatng, data[off:off + s])
55 append(e) 55 append(e)
56 n += 1 56 n += 1
57 off += s 57 off += s
58 58
59 if off != len(data):
60 raise ValueError('corrupt index file')
61
59 if index: 62 if index:
60 e = list(index[0]) 63 e = list(index[0])
61 type = gettype(e[0]) 64 type = gettype(e[0])
62 e[0] = offset_type(0, type) 65 e[0] = offset_type(0, type)
63 index[0] = tuple(e) 66 index[0] = tuple(e)