Show More
@@ -17,6 +17,21 b' Helper extension to intercept renames an' | |||||
17 | > extensions.wrapfunction(util.atomictempfile, 'close', close) |
|
17 | > extensions.wrapfunction(util.atomictempfile, 'close', close) | |
18 | > EOF |
|
18 | > EOF | |
19 |
|
19 | |||
|
20 | $ cat > $TESTTMP/intercept_after_rename.py << EOF | |||
|
21 | > import os | |||
|
22 | > import signal | |||
|
23 | > from mercurial import extensions, util | |||
|
24 | > | |||
|
25 | > def extsetup(ui): | |||
|
26 | > def close(orig, *args, **kwargs): | |||
|
27 | > path = util.normpath(args[0]._atomictempfile__name) | |||
|
28 | > r = orig(*args, **kwargs) | |||
|
29 | > if path.endswith(b'/.hg/store/data/file.i'): | |||
|
30 | > os.kill(os.getpid(), signal.SIGKILL) | |||
|
31 | > return r | |||
|
32 | > extensions.wrapfunction(util.atomictempfile, 'close', close) | |||
|
33 | > EOF | |||
|
34 | ||||
20 |
$ |
|
35 | $ cat > $TESTTMP/killme.py << EOF | |
21 | > import os |
|
36 | > import os | |
22 | > import signal |
|
37 | > import signal | |
@@ -197,6 +212,85 b' The data file is created, but the revlog' | |||||
197 | $ hg verify -q |
|
212 | $ hg verify -q | |
198 | $ cd .. |
|
213 | $ cd .. | |
199 |
|
214 | |||
|
215 | Test a hard crash right after the index is move into place | |||
|
216 | =========================================================== | |||
|
217 | ||||
|
218 | Now retry the procedure but intercept the rename of the index. | |||
|
219 | ||||
|
220 | Things get corrupted /o\ | |||
|
221 | ||||
|
222 | $ hg clone --quiet --rev 1 troffset-computation troffset-computation-crash-after-rename | |||
|
223 | $ cd troffset-computation-crash-after-rename | |||
|
224 | ||||
|
225 | Reference size: | |||
|
226 | $ f -s file | |||
|
227 | file: size=1024 | |||
|
228 | $ f -s .hg/store/data/file* | |||
|
229 | .hg/store/data/file.i: size=1174 | |||
|
230 | ||||
|
231 | $ cat > .hg/hgrc <<EOF | |||
|
232 | > [extensions] | |||
|
233 | > intercept_rename = $TESTTMP/intercept_after_rename.py | |||
|
234 | > [hooks] | |||
|
235 | > pretxnchangegroup = python:$TESTTMP/killme.py:killme | |||
|
236 | > EOF | |||
|
237 | #if chg | |||
|
238 | $ hg pull ../troffset-computation | |||
|
239 | pulling from ../troffset-computation | |||
|
240 | [255] | |||
|
241 | #else | |||
|
242 | $ hg pull ../troffset-computation | |||
|
243 | pulling from ../troffset-computation | |||
|
244 | Killed | |||
|
245 | [137] | |||
|
246 | #endif | |||
|
247 | ||||
|
248 | the revlog has been split on disk | |||
|
249 | ||||
|
250 | $ f -s .hg/store/data/file* | |||
|
251 | .hg/store/data/file.d: size=132139 | |||
|
252 | .hg/store/data/file.i: size=256 | |||
|
253 | ||||
|
254 | $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | |||
|
255 | data/file.i 1174 | |||
|
256 | data/file.d 0 | |||
|
257 | data/file.d 1046 | |||
|
258 | ||||
|
259 | $ hg recover | |||
|
260 | rolling back interrupted transaction | |||
|
261 | abort: attempted to truncate data/file.i to 1174 bytes, but it was already 256 bytes | |||
|
262 | ||||
|
263 | [255] | |||
|
264 | $ f -s .hg/store/data/file* | |||
|
265 | .hg/store/data/file.d: size=1046 | |||
|
266 | .hg/store/data/file.i: size=256 | |||
|
267 | $ hg tip | |||
|
268 | changeset: 1:cfa8d6e60429 | |||
|
269 | tag: tip | |||
|
270 | user: test | |||
|
271 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
272 | summary: b | |||
|
273 | ||||
|
274 | $ hg verify -q | |||
|
275 | abandoned transaction found - run hg recover | |||
|
276 | warning: revlog 'data/file.d' not in fncache! | |||
|
277 | file@0: data length off by -131093 bytes | |||
|
278 | file@2: unpacking fa1120531cc1: partial read of revlog data/file.d; expected 21 bytes from offset 1046, got 0 | |||
|
279 | file@3: unpacking a631378adaa3: partial read of revlog data/file.d; expected 131072 bytes from offset 1067, got -21 | |||
|
280 | file@?: rev 2 points to nonexistent changeset 2 | |||
|
281 | (expected ) | |||
|
282 | file@?: fa1120531cc1 not in manifests | |||
|
283 | file@?: rev 3 points to nonexistent changeset 3 | |||
|
284 | (expected ) | |||
|
285 | file@?: a631378adaa3 not in manifests | |||
|
286 | not checking dirstate because of previous errors | |||
|
287 | 3 warnings encountered! | |||
|
288 | hint: run "hg debugrebuildfncache" to recover from corrupt fncache | |||
|
289 | 7 integrity errors encountered! | |||
|
290 | (first damaged changeset appears to be 0) | |||
|
291 | [1] | |||
|
292 | $ cd .. | |||
|
293 | ||||
200 | Have the transaction rollback itself without any hard crash |
|
294 | Have the transaction rollback itself without any hard crash | |
201 | =========================================================== |
|
295 | =========================================================== | |
202 |
|
296 |
General Comments 0
You need to be logged in to leave comments.
Login now