Show More
@@ -0,0 +1,52 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | # | |||
|
3 | # revlog.parseindex must be able to parse the index file even if | |||
|
4 | # an index entry is split between two 64k blocks. The ideal test | |||
|
5 | # would be to create an index file with inline data where | |||
|
6 | # 64k < size < 64k + 64 (64k is the size of the read buffer, 64 is | |||
|
7 | # the size of an index entry) and with an index entry starting right | |||
|
8 | # before the 64k block boundary, and try to read it. | |||
|
9 | # | |||
|
10 | # We approximate that by reducing the read buffer to 1 byte. | |||
|
11 | # | |||
|
12 | ||||
|
13 | hg init a | |||
|
14 | cd a | |||
|
15 | echo abc > foo | |||
|
16 | hg add foo | |||
|
17 | hg commit -m 'add foo' -d '1000000 0' | |||
|
18 | ||||
|
19 | echo >> foo | |||
|
20 | hg commit -m 'change foo' -d '1000001 0' | |||
|
21 | hg log -r 0: | |||
|
22 | ||||
|
23 | cat >> test.py << EOF | |||
|
24 | from mercurial import changelog, util | |||
|
25 | from mercurial.node import * | |||
|
26 | ||||
|
27 | class singlebyteread(object): | |||
|
28 | def __init__(self, real): | |||
|
29 | self.real = real | |||
|
30 | ||||
|
31 | def read(self, size=-1): | |||
|
32 | if size == 65536: | |||
|
33 | size = 1 | |||
|
34 | return self.real.read(size) | |||
|
35 | ||||
|
36 | def __getattr__(self, key): | |||
|
37 | return getattr(self.real, key) | |||
|
38 | ||||
|
39 | def opener(*args): | |||
|
40 | o = util.opener(*args) | |||
|
41 | def wrapper(*a): | |||
|
42 | f = o(*a) | |||
|
43 | return singlebyteread(f) | |||
|
44 | return wrapper | |||
|
45 | ||||
|
46 | cl = changelog.changelog(opener('.hg')) | |||
|
47 | print cl.count(), 'revisions:' | |||
|
48 | for r in xrange(cl.count()): | |||
|
49 | print short(cl.node(r)) | |||
|
50 | EOF | |||
|
51 | ||||
|
52 | python test.py |
@@ -0,0 +1,14 b'' | |||||
|
1 | changeset: 0:9c2cf2b35aa7 | |||
|
2 | user: test | |||
|
3 | date: Mon Jan 12 13:46:40 1970 +0000 | |||
|
4 | summary: add foo | |||
|
5 | ||||
|
6 | changeset: 1:3756a9556b89 | |||
|
7 | tag: tip | |||
|
8 | user: test | |||
|
9 | date: Mon Jan 12 13:46:41 1970 +0000 | |||
|
10 | summary: change foo | |||
|
11 | ||||
|
12 | 2 revisions: | |||
|
13 | 9c2cf2b35aa7 | |||
|
14 | 3756a9556b89 |
@@ -405,19 +405,17 b' class revlog(object):' | |||||
405 | if n == 0 and self.inlinedata(): |
|
405 | if n == 0 and self.inlinedata(): | |
406 | # cache the first chunk |
|
406 | # cache the first chunk | |
407 | self.chunkcache = (0, data) |
|
407 | self.chunkcache = (0, data) | |
|
408 | if leftover: | |||
|
409 | data = leftover + data | |||
|
410 | leftover = None | |||
408 | off = 0 |
|
411 | off = 0 | |
409 | l = len(data) |
|
412 | l = len(data) | |
410 | while off < l: |
|
413 | while off < l: | |
411 | if l - off < s: |
|
414 | if l - off < s: | |
412 | leftover = data[off:] |
|
415 | leftover = data[off:] | |
413 | break |
|
416 | break | |
414 | if leftover: |
|
417 | cur = data[off:off + s] | |
415 | cur = leftover + data[off:off + s - len(leftover)] |
|
418 | off += s | |
416 | off += s - len(leftover) |
|
|||
417 | leftover = None |
|
|||
418 | else: |
|
|||
419 | cur = data[off:off + s] |
|
|||
420 | off += s |
|
|||
421 | e = struct.unpack(self.indexformat, cur) |
|
419 | e = struct.unpack(self.indexformat, cur) | |
422 | self.index.append(e) |
|
420 | self.index.append(e) | |
423 | self.nodemap[e[-1]] = n |
|
421 | self.nodemap[e[-1]] = n |
General Comments 0
You need to be logged in to leave comments.
Login now