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 |
General Comments 0
You need to be logged in to leave comments.
Login now