Mercurial > hg
annotate tests/test-parseindex @ 2320:dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
old code read every head of .hgtags. delete and recreate of .hgtags gave
new head, but if error in deleted rev, .hgtags had error messages every
time it was parsed. this was very hard to fix, because deleted revs hard
to get back and update, needed merges too.
new code reads .hgtags on every head. advantage is if parse error
happens with new code, is possible to fix them by editing .hgtags on a
head and committing.
NOTE: new code uses binary search of manifest of each head to be fast,
but still much slower than old code. best thing would be to have delete
record stored in filelog so we never touch manifest. could find live
heads directly from filelog. this is more work than i want now.
new tests check for parse of tags on different heads, and inaccessible
heads created by delete and recreate of .hgtags.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Thu, 18 May 2006 23:31:12 -0700 |
parents | 6563438219e3 |
children | c0b449154a90 |
rev | line source |
---|---|
2290
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
1 #!/bin/sh |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
2 # |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
3 # revlog.parseindex must be able to parse the index file even if |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
4 # an index entry is split between two 64k blocks. The ideal test |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
5 # would be to create an index file with inline data where |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
6 # 64k < size < 64k + 64 (64k is the size of the read buffer, 64 is |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
7 # the size of an index entry) and with an index entry starting right |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
8 # before the 64k block boundary, and try to read it. |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
9 # |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
10 # We approximate that by reducing the read buffer to 1 byte. |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
11 # |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
12 |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
13 hg init a |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
14 cd a |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
15 echo abc > foo |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
16 hg add foo |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
17 hg commit -m 'add foo' -d '1000000 0' |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
18 |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
19 echo >> foo |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
20 hg commit -m 'change foo' -d '1000001 0' |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
21 hg log -r 0: |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
22 |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
23 cat >> test.py << EOF |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
24 from mercurial import changelog, util |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
25 from mercurial.node import * |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
26 |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
27 class singlebyteread(object): |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
28 def __init__(self, real): |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
29 self.real = real |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
30 |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
31 def read(self, size=-1): |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
32 if size == 65536: |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
33 size = 1 |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
34 return self.real.read(size) |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
35 |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
36 def __getattr__(self, key): |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
37 return getattr(self.real, key) |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
38 |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
39 def opener(*args): |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
40 o = util.opener(*args) |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
41 def wrapper(*a): |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
42 f = o(*a) |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
43 return singlebyteread(f) |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
44 return wrapper |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
45 |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
46 cl = changelog.changelog(opener('.hg')) |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
47 print cl.count(), 'revisions:' |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
48 for r in xrange(cl.count()): |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
49 print short(cl.node(r)) |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
50 EOF |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
51 |
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
52 python test.py |