Debian Codegraph @

tests/test-verify.t

raw
1 #testcases fncache fileindex
2
3 #if fileindex
4 $ cat >> $HGRCPATH << EOF
5 > [format]
6 > use-fileindex-v1=yes
7 > EOF
8 #else
9 $ cat >> $HGRCPATH << EOF
10 > [format]
11 > use-fileindex-v1=no
12 > EOF
13 #endif
14
15 #if fileindex no-rust
16 $ cat >> $HGRCPATH << EOF
17 > [storage]
18 > fileindex.slow-path=allow
19 > EOF
20 #endif
21
22 prepare repo
23
24 $ hg init a
25 $ cd a
26 $ echo "some text" > FOO.txt
27 $ echo "another text" > bar.txt
28 $ echo "more text" > QUICK.txt
29 $ hg add
30 adding FOO.txt
31 adding QUICK.txt
32 adding bar.txt
33 $ hg ci -mtest1
34
35 verify
36
37 $ hg verify
38 checking changesets
39 checking manifests
40 crosschecking files in changesets and manifests
41 checking files
42 checking dirstate
43 checked 1 changesets with 3 changes to 3 files
44
45 verify with journal
46
47 $ touch .hg/store/journal
48 $ hg verify
49 abandoned transaction found - run hg recover
50 checking changesets
51 checking manifests
52 crosschecking files in changesets and manifests
53 checking files
54 checking dirstate
55 checked 1 changesets with 3 changes to 3 files
56 $ rm .hg/store/journal
57
58 introduce some bugs in repo
59
60 $ cd .hg/store/data
61 $ mv _f_o_o.txt.i X_f_o_o.txt.i
62 $ mv bar.txt.i xbar.txt.i
63 $ rm _q_u_i_c_k.txt.i
64
65 $ hg verify
66 checking changesets
67 checking manifests
68 crosschecking files in changesets and manifests
69 checking files
70 0: empty or missing FOO.txt
71 FOO.txt@0: manifest refers to unknown revision f62022d3d590
72 0: empty or missing QUICK.txt
73 QUICK.txt@0: manifest refers to unknown revision 88b857db8eba
74 0: empty or missing bar.txt
75 bar.txt@0: manifest refers to unknown revision 256559129457
76 not checking dirstate because of previous errors
77 checked 1 changesets with 0 changes to 3 files
78 6 integrity errors encountered!
79 (first damaged changeset appears to be 0)
80 [1]
81
82 $ cd ../../..
83 $ cd ..
84
85 Set up a repo for testing missing revlog entries
86
87 $ hg init missing-entries
88 $ cd missing-entries
89 $ echo 0 > file
90 $ hg ci -Aqm0
91 $ cp -R .hg/store .hg/store-partial
92 $ echo 1 > file
93 $ hg ci -Aqm1
94 $ cp -R .hg/store .hg/store-full
95
96 Entire changelog missing
97
98 $ rm .hg/store/00changelog.*
99 $ hg verify -q
100 0: empty or missing changelog
101 manifest@0: d0b6632564d4 not in changesets
102 manifest@1: 941fc4534185 not in changesets
103 not checking dirstate because of previous errors
104 3 integrity errors encountered!
105 (first damaged changeset appears to be 0)
106 [1]
107 $ cp -R .hg/store-full/. .hg/store
108
109 Entire manifest log missing
110
111 $ rm .hg/store/00manifest.*
112 $ hg verify -q
113 0: empty or missing manifest
114 not checking dirstate because of previous errors
115 1 integrity errors encountered!
116 (first damaged changeset appears to be 0)
117 [1]
118 $ cp -R .hg/store-full/. .hg/store
119
120 Entire filelog missing
121
122 $ rm .hg/store/data/file.*
123 $ hg verify -q
124 0: empty or missing file
125 file@0: manifest refers to unknown revision 362fef284ce2
126 file@1: manifest refers to unknown revision c10f2164107d
127 not checking dirstate because of previous errors
128 3 integrity errors encountered!
129 (first damaged changeset appears to be 0)
130 [1]
131 $ cp -R .hg/store-full/. .hg/store
132
133 Entire changelog and manifest log missing
134
135 $ rm .hg/store/00changelog.*
136 $ rm .hg/store/00manifest.*
137 $ hg verify -q
138 warning: orphan data file 'data/file.i' (fncache !)
139 warning: orphan file index entry 'file' (fileindex !)
140 warning: ignoring unknown working parent c5ddb05ab828!
141 file marked as tracked in p1 (000000000000) but not in manifest1
142 1 warnings encountered!
143 1 integrity errors encountered!
144 dirstate inconsistent with current parent's manifest
145 1 dirstate errors
146 [1]
147
148 We can check the dirstate in isolation
149 $ hg admin::verify -c dirstate
150 running 1 checks
151 running working-copy.dirstate
152 checking dirstate
153 warning: ignoring unknown working parent c5ddb05ab828!
154 file marked as tracked in p1 (000000000000) but not in manifest1
155 found 1 errors
156
157 $ cp -R .hg/store-full/. .hg/store
158
159 Entire changelog and filelog missing
160
161 $ rm .hg/store/00changelog.*
162 $ rm .hg/store/data/file.*
163 $ hg verify -q
164 0: empty or missing changelog
165 manifest@0: d0b6632564d4 not in changesets
166 manifest@1: 941fc4534185 not in changesets
167 ?: empty or missing file
168 file@0: manifest refers to unknown revision 362fef284ce2
169 file@1: manifest refers to unknown revision c10f2164107d
170 not checking dirstate because of previous errors
171 6 integrity errors encountered!
172 (first damaged changeset appears to be 0)
173 [1]
174 $ cp -R .hg/store-full/. .hg/store
175
176 Entire manifest log and filelog missing
177
178 $ rm .hg/store/00manifest.*
179 $ rm .hg/store/data/file.*
180 $ hg verify -q
181 0: empty or missing manifest
182 0: empty or missing file
183 not checking dirstate because of previous errors
184 2 integrity errors encountered!
185 (first damaged changeset appears to be 0)
186 [1]
187 $ cp -R .hg/store-full/. .hg/store
188
189 Changelog missing entry
190
191 $ cp -f .hg/store-partial/00changelog.* .hg/store
192 $ hg verify -q
193 manifest@?: rev 1 points to nonexistent changeset 1
194 manifest@?: 941fc4534185 not in changesets
195 file@?: rev 1 points to nonexistent changeset 1
196 (expected 0)
197 not checking dirstate because of previous errors
198 1 warnings encountered!
199 3 integrity errors encountered!
200 [1]
201 $ cp -R .hg/store-full/. .hg/store
202
203 Manifest log missing entry
204
205 $ cp -f .hg/store-partial/00manifest.* .hg/store
206 $ hg verify -q
207 manifest@1: changeset refers to unknown revision 941fc4534185
208 file@1: c10f2164107d not in manifests
209 not checking dirstate because of previous errors
210 2 integrity errors encountered!
211 (first damaged changeset appears to be 1)
212 [1]
213 $ cp -R .hg/store-full/. .hg/store
214
215 Filelog missing entry
216
217 $ cp -f .hg/store-partial/data/file.* .hg/store/data
218 $ hg verify -q
219 file@1: manifest refers to unknown revision c10f2164107d
220 not checking dirstate because of previous errors
221 1 integrity errors encountered!
222 (first damaged changeset appears to be 1)
223 [1]
224 $ cp -R .hg/store-full/. .hg/store
225
226 Changelog and manifest log missing entry
227
228 $ cp -f .hg/store-partial/00changelog.* .hg/store
229 $ cp -f .hg/store-partial/00manifest.* .hg/store
230 $ hg verify -q
231 file@?: rev 1 points to nonexistent changeset 1
232 (expected 0)
233 file@?: c10f2164107d not in manifests
234 not checking dirstate because of previous errors
235 1 warnings encountered!
236 2 integrity errors encountered!
237 [1]
238 $ cp -R .hg/store-full/. .hg/store
239
240 Changelog and filelog missing entry
241
242 $ cp -f .hg/store-partial/00changelog.* .hg/store
243 $ cp -f .hg/store-partial/data/file.* .hg/store/data
244 $ hg verify -q
245 manifest@?: rev 1 points to nonexistent changeset 1
246 manifest@?: 941fc4534185 not in changesets
247 file@?: manifest refers to unknown revision c10f2164107d
248 not checking dirstate because of previous errors
249 3 integrity errors encountered!
250 [1]
251 $ cp -R .hg/store-full/. .hg/store
252
253 Manifest and filelog missing entry
254
255 $ cp -f .hg/store-partial/00manifest.* .hg/store
256 $ cp -f .hg/store-partial/data/file.* .hg/store/data
257 $ hg verify -q
258 manifest@1: changeset refers to unknown revision 941fc4534185
259 not checking dirstate because of previous errors
260 1 integrity errors encountered!
261 (first damaged changeset appears to be 1)
262 [1]
263 $ cp -R .hg/store-full/. .hg/store
264
265 #if fncache
266
267 Fncache inconsistency case 1: missing entry.
268 We remove the last line of the fncache, making it incomplete.
269 This is a problem because streamclone would omit the file.
270
271 $ sed '$d' .hg/store/fncache > .hg/store/fncache-tmp
272 $ mv .hg/store/fncache-tmp .hg/store/fncache
273 $ hg verify -q
274 warning: revlog 'data/file.i' not in fncache!
275 1 warnings encountered!
276 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
277 $ cp -R .hg/store-full/. .hg/store
278
279 Fncache inconsistency case 2a: extra entry (nonexistent).
280 We add an extra line to the fncache, referencing a file that doesn't exist.
281 This is a problem because streamclone would try to read this file and fail.
282
283 $ echo "data/bad-nonexistent.i" >> .hg/store/fncache
284 $ hg verify -q
285 warning: orphan data file 'data/bad-nonexistent.i'
286 1 warnings encountered!
287 $ cp -R .hg/store-full/. .hg/store
288
289 Fncache inconsistency case 2b: extra entry (empty).
290 We add an extra line to the fncache, which refers to an empty file.
291 This is a problem because it's an orphan file that shouldn't be there.
292
293 $ echo "data/bad-empty.i" >> .hg/store/fncache
294 $ touch .hg/store/data/bad-empty.i
295 $ hg verify -q
296 warning: orphan data file 'data/bad-empty.i'
297 1 warnings encountered!
298 $ rm .hg/store/data/bad-empty.i
299 $ cp -R .hg/store-full/. .hg/store
300 $ cp -R .hg/store-full/. .hg/store
301
302 Fncache inconsistency case 2c: extra entry (nonempty).
303 We add an extra line to the fncache, which refers to a nonempty file.
304 This is a problem because it's an orphan file that shouldn't be there.
305
306 $ echo "data/bad-nonempty.i" >> .hg/store/fncache
307 $ printf x > .hg/store/data/bad-nonempty.i
308 $ hg verify -q
309 warning: orphan data file 'data/bad-nonempty.i'
310 1 warnings encountered!
311 $ rm .hg/store/data/bad-nonempty.i
312 $ cp -R .hg/store-full/. .hg/store
313
314 #else
315
316 This section tests the same inconsistencies as above (1, 2a, 2b, 2c)
317 but using the file index instead of the fncache.
318
319 An extension for directly editing the file index.
320 $ cat > "$TESTTMP/edit_fileindex.py" << EOF
321 > from mercurial import registrar
322 > cmdtable = {}
323 > command = registrar.command(cmdtable)
324 > @command(b"fileindex-add")
325 > def file_index_add(ui, repo, path):
326 > with repo.lock(), repo.transaction(b'fileindex-add') as tr:
327 > repo.store.fileindex.add(path, tr)
328 > @command(b"fileindex-remove")
329 > def file_index_remove(ui, repo, path):
330 > with repo.lock(), repo.transaction(b'fileindex-remove') as tr:
331 > repo.store.fileindex.remove(path, tr)
332 > EOF
333
334 File index inconsistency case 1: missing entry.
335 We remove an entry from the file index while leaving its revlog in place.
336 This is a problem because streamclone would omit the file.
337
338 $ hg fileindex-remove file --config extensions.edit_fileindex="$TESTTMP/edit_fileindex.py"
339 $ hg verify -q
340 warning: revlog 'file' not in file index!
341 1 warnings encountered!
342 $ cp -R .hg/store-full/. .hg/store
343
344 File index inconsistency case 2a: extra entry (nonexistent).
345 We add an entry to the file index referencing a revlog that doesn't exist.
346 This is a problem because streamclone would try to read this file and fail.
347
348 $ hg fileindex-add bad-nonexistent --config extensions.edit_fileindex="$TESTTMP/edit_fileindex.py"
349 $ hg verify -q
350 warning: orphan file index entry 'bad-nonexistent'
351 1 warnings encountered!
352 $ cp -R .hg/store-full/. .hg/store
353
354 File index inconsistency case 2b: extra entry (empty).
355 We add an entry to the file index referencing an empty revlog.
356 This is a problem because it's an orphan file that shouldn't be there.
357
358 $ hg fileindex-add bad-empty --config extensions.edit_fileindex="$TESTTMP/edit_fileindex.py"
359 $ touch .hg/store/data/bad-empty.i
360 $ hg verify -q
361 warning: orphan file index entry 'bad-empty'
362 1 warnings encountered!
363 $ rm .hg/store/data/bad-empty.i
364 $ cp -R .hg/store-full/. .hg/store
365
366 File index inconsistency case 2c: extra entry (nonempty).
367 We add an entry to the file index referencing a nonempty revlog.
368 This is a problem because it's an orphan file that shouldn't be there.
369
370 $ hg fileindex-add bad-nonempty --config extensions.edit_fileindex="$TESTTMP/edit_fileindex.py"
371 $ printf x > .hg/store/data/bad-nonempty.i
372 $ hg verify -q
373 warning: orphan file index entry 'bad-nonempty'
374 1 warnings encountered!
375 $ rm .hg/store/data/bad-nonempty.i
376 $ cp -R .hg/store-full/. .hg/store
377
378 #endif
379
380 Corrupt changelog base node to cause failure to read revision
381
382 $ printf abcd | dd conv=notrunc of=.hg/store/00changelog.i bs=1 seek=16 \
383 > 2> /dev/null
384 $ hg verify -q
385 0: unpacking changeset 08b1860757c2: * (glob)
386 manifest@?: rev 0 points to unexpected changeset 0
387 manifest@?: d0b6632564d4 not in changesets
388 file@?: rev 0 points to unexpected changeset 0
389 (expected 1)
390 not checking dirstate because of previous errors
391 1 warnings encountered!
392 4 integrity errors encountered!
393 (first damaged changeset appears to be 0)
394 [1]
395 $ cp -R .hg/store-full/. .hg/store
396
397 Corrupt manifest log base node to cause failure to read revision
398
399 $ printf abcd | dd conv=notrunc of=.hg/store/00manifest.i bs=1 seek=16 \
400 > 2> /dev/null
401 $ hg verify -q
402 manifest@0: reading delta d0b6632564d4: * (glob)
403 file@0: 362fef284ce2 not in manifests
404 not checking dirstate because of previous errors
405 2 integrity errors encountered!
406 (first damaged changeset appears to be 0)
407 [1]
408 $ cp -R .hg/store-full/. .hg/store
409
410 Corrupt filelog base node to cause failure to read revision
411
412 $ printf abcd | dd conv=notrunc of=.hg/store/data/file.i bs=1 seek=16 \
413 > 2> /dev/null
414 $ hg verify -q
415 file@0: unpacking 362fef284ce2: * (glob)
416 not checking dirstate because of previous errors
417 1 integrity errors encountered!
418 (first damaged changeset appears to be 0)
419 [1]
420 $ cp -R .hg/store-full/. .hg/store
421
422 $ cd ..
423
424 test changelog without a manifest
425
426 $ hg init b
427 $ cd b
428 $ hg branch foo
429 marked working directory as branch foo
430 (branches are permanent and global, did you want a bookmark?)
431 $ hg ci -m branchfoo
432 $ hg verify -q
433
434 test revlog corruption
435
436 $ touch a
437 $ hg add a
438 $ hg ci -m a
439
440 $ echo 'corrupted' > b
441 $ dd if=.hg/store/data/a.i of=start bs=1 count=20 2>/dev/null
442 $ cat start b > .hg/store/data/a.i
443
444 $ hg verify -q
445 a@1: broken revlog! (index a is corrupted) (no-rust !)
446 a@1: broken revlog! (abort: unexpected inline revlog length) (rust !)
447 warning: orphan data file 'data/a.i' (fncache !)
448 warning: orphan file index entry 'a' (fileindex !)
449 not checking dirstate because of previous errors
450 1 warnings encountered!
451 1 integrity errors encountered!
452 (first damaged changeset appears to be 1)
453 [1]
454
455 $ cd ..
456
457 test revlog format 0
458
459 $ revlog-formatv0.py
460 $ cd formatv0
461 $ hg verify
462 repository uses revlog format 0
463 checking changesets
464 checking manifests
465 crosschecking files in changesets and manifests
466 checking files
467 checking dirstate
468 checked 1 changesets with 1 changes to 1 files
469 $ cd ..
470
471 # rust index does not allow creation of new flags dynamically
472 #if no-rust
473
474 test flag processor and skipflags
475
476 $ hg init skipflags
477 $ cd skipflags
478 $ cat >> .hg/hgrc <<EOF
479 > [extensions]
480 > flagprocessor=$RUNTESTDIR/flagprocessorext.py
481 > EOF
482 $ echo '[BASE64]content' > base64
483 $ hg commit -Aqm 'flag processor content' base64
484 $ hg verify -q
485
486 $ cat >> $TESTTMP/break-base64.py <<EOF
487 > import base64
488 > base64.b64decode=lambda x: x
489 > EOF
490 $ cat >> .hg/hgrc <<EOF
491 > breakbase64=$TESTTMP/break-base64.py
492 > EOF
493
494 $ hg verify -q
495 base64@0: unpacking 794cee7777cb: integrity check failed on base64:0
496 not checking dirstate because of previous errors
497 1 integrity errors encountered!
498 (first damaged changeset appears to be 0)
499 [1]
500 $ hg verify --config verify.skipflags=2147483647 -q
501
502 #endif