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