Show More
@@ -1,22 +1,62 b'' | |||
|
1 | 1 | Test correctness of revlog inline -> non-inline transition |
|
2 | 2 | ---------------------------------------------------------- |
|
3 | 3 | |
|
4 |
Helper extension to intercept renames |
|
|
4 | Helper extension to intercept renames and kill process | |
|
5 | 5 | |
|
6 | $ cat > $TESTTMP/intercept_rename.py << EOF | |
|
6 | $ cat > $TESTTMP/intercept_before_rename.py << EOF | |
|
7 | 7 | > import os |
|
8 |
> import s |
|
|
8 | > import signal | |
|
9 | 9 | > from mercurial import extensions, util |
|
10 | 10 | > |
|
11 | 11 | > def extsetup(ui): |
|
12 | 12 | > def close(orig, *args, **kwargs): |
|
13 | 13 | > path = util.normpath(args[0]._atomictempfile__name) |
|
14 | 14 | > if path.endswith(b'/.hg/store/data/file.i'): |
|
15 | > os._exit(80) | |
|
15 | > os.kill(os.getpid(), signal.SIGKILL) | |
|
16 | 16 | > return orig(*args, **kwargs) |
|
17 | 17 | > extensions.wrapfunction(util.atomictempfile, 'close', close) |
|
18 | 18 | > EOF |
|
19 | 19 | |
|
20 | $ cat > $TESTTMP/killme.py << EOF | |
|
21 | > import os | |
|
22 | > import signal | |
|
23 | > | |
|
24 | > def killme(ui, repo, hooktype, **kwargs): | |
|
25 | > os.kill(os.getpid(), signal.SIGKILL) | |
|
26 | > EOF | |
|
27 | ||
|
28 | setup a repository for tests | |
|
29 | ---------------------------- | |
|
30 | ||
|
31 | $ cat >> $HGRCPATH << EOF | |
|
32 | > [format] | |
|
33 | > revlog-compression=none | |
|
34 | > EOF | |
|
35 | ||
|
36 | $ hg init troffset-computation | |
|
37 | $ cd troffset-computation | |
|
38 | $ printf '%20d' '1' > file | |
|
39 | $ hg commit -Aqma | |
|
40 | $ printf '%1024d' '1' > file | |
|
41 | $ hg commit -Aqmb | |
|
42 | $ printf '%20d' '1' > file | |
|
43 | $ hg commit -Aqmc | |
|
44 | $ dd if=/dev/zero of=file bs=1k count=128 > /dev/null 2>&1 | |
|
45 | $ hg commit -AqmD | |
|
46 | ||
|
47 | Reference size: | |
|
48 | $ f -s file | |
|
49 | file: size=131072 | |
|
50 | $ f -s .hg/store/data/file* | |
|
51 | .hg/store/data/file.d: size=132139 | |
|
52 | .hg/store/data/file.i: size=256 | |
|
53 | ||
|
54 | $ cd .. | |
|
55 | ||
|
56 | ||
|
57 | Test a hard crash after the file was split but before the transaction was committed | |
|
58 | =================================================================================== | |
|
59 | ||
|
20 | 60 | Test offset computation to correctly factor in the index entries themselves. |
|
21 | 61 | Also test that the new data size has the correct size if the transaction is aborted |
|
22 | 62 | after the index has been replaced. |
@@ -28,30 +68,19 b' and will transition to non-inline storag' | |||
|
28 | 68 | If the transaction adding c, D is rolled back, then we don't undo the revlog split, |
|
29 | 69 | but truncate the index and the data to remove both c and D. |
|
30 | 70 | |
|
31 | $ hg init troffset-computation --config format.revlog-compression=none | |
|
32 | $ cd troffset-computation | |
|
33 | $ printf '%20d' '1' > file | |
|
34 | $ hg commit -Aqma | |
|
35 | $ printf '%1024d' '1' > file | |
|
36 | $ hg commit -Aqmb | |
|
37 | $ printf '%20d' '1' > file | |
|
38 | $ hg commit -Aqmc | |
|
39 | $ dd if=/dev/zero of=file bs=1k count=128 > /dev/null 2>&1 | |
|
40 | $ hg commit -AqmD | |
|
41 | 71 | |
|
42 | $ cd .. | |
|
43 | ||
|
44 | $ hg clone -r 1 troffset-computation troffset-computation-copy --config format.revlog-compression=none -q | |
|
72 | $ hg clone --quiet --rev 1 troffset-computation troffset-computation-copy | |
|
45 | 73 | $ cd troffset-computation-copy |
|
46 | 74 | |
|
47 | 75 | Reference size: |
|
48 | ||
|
76 | $ f -s file | |
|
77 | file: size=1024 | |
|
49 | 78 | $ f -s .hg/store/data/file* |
|
50 | 79 | .hg/store/data/file.i: size=1174 |
|
51 | 80 | |
|
52 | 81 | $ cat > .hg/hgrc <<EOF |
|
53 | 82 | > [hooks] |
|
54 |
> pretxnchangegroup = python:$TEST |
|
|
83 | > pretxnchangegroup = python:$TESTTMP/killme.py:killme | |
|
55 | 84 | > EOF |
|
56 | 85 | #if chg |
|
57 | 86 | $ hg pull ../troffset-computation |
@@ -60,14 +89,24 b' Reference size:' | |||
|
60 | 89 | #else |
|
61 | 90 | $ hg pull ../troffset-computation |
|
62 | 91 | pulling from ../troffset-computation |
|
63 | [80] | |
|
92 | Killed | |
|
93 | [137] | |
|
64 | 94 | #endif |
|
95 | ||
|
96 | ||
|
97 | The revlog have been split on disk | |
|
98 | ||
|
99 | $ f -s .hg/store/data/file* | |
|
100 | .hg/store/data/file.d: size=132139 | |
|
101 | .hg/store/data/file.i: size=256 | |
|
102 | ||
|
65 | 103 | $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | tail -1 |
|
66 | 104 | data/file.i 128 |
|
67 | 105 | |
|
68 | 106 | The first file.i entry should match the "Reference size" above. |
|
69 | 107 | The first file.d entry is the temporary record during the split, |
|
70 | the second entry after the split happened. The sum of the second file.d | |
|
108 | ||
|
109 | The second entry after the split happened. The sum of the second file.d | |
|
71 | 110 | and the second file.i entry should match the first file.i entry. |
|
72 | 111 | |
|
73 | 112 | $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file |
@@ -98,18 +137,27 b' and the second file.i entry should match' | |||
|
98 | 137 | $ hg verify -q |
|
99 | 138 | $ cd .. |
|
100 | 139 | |
|
140 | Test a hard crash right before the index is move into place | |
|
141 | =========================================================== | |
|
101 | 142 | |
|
102 | 143 | Now retry the procedure but intercept the rename of the index and check that |
|
103 | 144 | the journal does not contain the new index size. This demonstrates the edge case |
|
104 | 145 | where the data file is left as garbage. |
|
105 | 146 | |
|
106 |
$ hg clone -r 1 troffset-computation troffset-computation-copy2 |
|
|
147 | $ hg clone --quiet --rev 1 troffset-computation troffset-computation-copy2 | |
|
107 | 148 | $ cd troffset-computation-copy2 |
|
149 | ||
|
150 | Reference size: | |
|
151 | $ f -s file | |
|
152 | file: size=1024 | |
|
153 | $ f -s .hg/store/data/file* | |
|
154 | .hg/store/data/file.i: size=1174 | |
|
155 | ||
|
108 | 156 | $ cat > .hg/hgrc <<EOF |
|
109 | 157 | > [extensions] |
|
110 | > intercept_rename = $TESTTMP/intercept_rename.py | |
|
158 | > intercept_rename = $TESTTMP/intercept_before_rename.py | |
|
111 | 159 | > [hooks] |
|
112 |
> pretxnchangegroup = python:$TEST |
|
|
160 | > pretxnchangegroup = python:$TESTTMP/killme.py:killme | |
|
113 | 161 | > EOF |
|
114 | 162 | #if chg |
|
115 | 163 | $ hg pull ../troffset-computation |
@@ -118,8 +166,16 b' where the data file is left as garbage.' | |||
|
118 | 166 | #else |
|
119 | 167 | $ hg pull ../troffset-computation |
|
120 | 168 | pulling from ../troffset-computation |
|
121 | [80] | |
|
169 | Killed | |
|
170 | [137] | |
|
122 | 171 | #endif |
|
172 | ||
|
173 | The data file is created, but the revlog is still inline | |
|
174 | ||
|
175 | $ f -s .hg/store/data/file* | |
|
176 | .hg/store/data/file.d: size=132139 | |
|
177 | .hg/store/data/file.i: size=132395 | |
|
178 | ||
|
123 | 179 | $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file |
|
124 | 180 | data/file.i 1174 |
|
125 | 181 | data/file.d 0 |
@@ -141,10 +197,13 b' where the data file is left as garbage.' | |||
|
141 | 197 | $ hg verify -q |
|
142 | 198 | $ cd .. |
|
143 | 199 | |
|
200 | Have the transaction rollback itself without any hard crash | |
|
201 | =========================================================== | |
|
202 | ||
|
144 | 203 | |
|
145 | 204 | Repeat the original test but let hg rollback the transaction. |
|
146 | 205 | |
|
147 |
$ hg clone -r 1 troffset-computation troffset-computation-copy-rb |
|
|
206 | $ hg clone --quiet --rev 1 troffset-computation troffset-computation-copy-rb | |
|
148 | 207 | $ cd troffset-computation-copy-rb |
|
149 | 208 | $ cat > .hg/hgrc <<EOF |
|
150 | 209 | > [hooks] |
@@ -160,9 +219,13 b' Repeat the original test but let hg roll' | |||
|
160 | 219 | rollback completed |
|
161 | 220 | abort: pretxnchangegroup hook exited with status 1 |
|
162 | 221 | [40] |
|
222 | ||
|
223 | File are still split on disk, with the expected size. | |
|
224 | ||
|
163 | 225 | $ f -s .hg/store/data/file* |
|
164 | 226 | .hg/store/data/file.d: size=1046 |
|
165 | 227 | .hg/store/data/file.i: size=128 |
|
228 | ||
|
166 | 229 | $ hg tip |
|
167 | 230 | changeset: 1:cfa8d6e60429 |
|
168 | 231 | tag: tip |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now