Show More
@@ -1,52 +1,59 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' | |
|
18 | ||
|
19 | echo >> foo | |
|
20 | hg commit -m 'change foo' | |
|
21 | hg log -r 0: | |
|
22 | ||
|
23 | cat >> test.py << EOF | |
|
24 | from mercurial import changelog, util | |
|
25 | from mercurial.node import * | |
|
1 | revlog.parseindex must be able to parse the index file even if | |
|
2 | an index entry is split between two 64k blocks. The ideal test | |
|
3 | would be to create an index file with inline data where | |
|
4 | 64k < size < 64k + 64 (64k is the size of the read buffer, 64 is | |
|
5 | the size of an index entry) and with an index entry starting right | |
|
6 | before the 64k block boundary, and try to read it. | |
|
7 | We approximate that by reducing the read buffer to 1 byte. | |
|
26 | 8 | |
|
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/store')) | |
|
47 | print len(cl), 'revisions:' | |
|
48 | for r in cl: | |
|
49 | print short(cl.node(r)) | |
|
50 | EOF | |
|
51 | ||
|
52 | python test.py | |
|
9 | $ hg init a | |
|
10 | $ cd a | |
|
11 | $ echo abc > foo | |
|
12 | $ hg add foo | |
|
13 | $ hg commit -m 'add foo' | |
|
14 | $ echo >> foo | |
|
15 | $ hg commit -m 'change foo' | |
|
16 | $ hg log -r 0: | |
|
17 | changeset: 0:7c31755bf9b5 | |
|
18 | user: test | |
|
19 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
20 | summary: add foo | |
|
21 | ||
|
22 | changeset: 1:26333235a41c | |
|
23 | tag: tip | |
|
24 | user: test | |
|
25 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
26 | summary: change foo | |
|
27 | ||
|
28 | $ cat >> test.py << EOF | |
|
29 | > from mercurial import changelog, util | |
|
30 | > from mercurial.node import * | |
|
31 | > | |
|
32 | > class singlebyteread(object): | |
|
33 | > def __init__(self, real): | |
|
34 | > self.real = real | |
|
35 | > | |
|
36 | > def read(self, size=-1): | |
|
37 | > if size == 65536: | |
|
38 | > size = 1 | |
|
39 | > return self.real.read(size) | |
|
40 | > | |
|
41 | > def __getattr__(self, key): | |
|
42 | > return getattr(self.real, key) | |
|
43 | > | |
|
44 | > def opener(*args): | |
|
45 | > o = util.opener(*args) | |
|
46 | > def wrapper(*a): | |
|
47 | > f = o(*a) | |
|
48 | > return singlebyteread(f) | |
|
49 | > return wrapper | |
|
50 | > | |
|
51 | > cl = changelog.changelog(opener('.hg/store')) | |
|
52 | > print len(cl), 'revisions:' | |
|
53 | > for r in cl: | |
|
54 | > print short(cl.node(r)) | |
|
55 | > EOF | |
|
56 | $ python test.py | |
|
57 | 2 revisions: | |
|
58 | 7c31755bf9b5 | |
|
59 | 26333235a41c |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now