comparison tests/test-dirstate-version-fallback.t @ 50660:bf16ef96defe stable

rust-dirstate: fall back to v1 if reading v2 failed This will help us not fail when a v1 dirstate is present on disk while a v2 was expected (which could happen with a racy/interrupted upgrade).
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 05 Jun 2023 16:43:27 +0200
parents 9e08cfbe77b1
children e7a3611181aa
comparison
equal deleted inserted replaced
50659:9e08cfbe77b1 50660:bf16ef96defe
18 Copy v1 dirstate 18 Copy v1 dirstate
19 $ cp .hg/dirstate $TESTTMP/dirstate-v1-backup 19 $ cp .hg/dirstate $TESTTMP/dirstate-v1-backup
20 20
21 Upgrade it to v2 21 Upgrade it to v2
22 22
23 $ hg debugupgraderepo -q --config format.use-dirstate-v2=1 --run | grep added 23 $ hg debugupgraderepo -q --config format.use-dirstate-v2=1 --run | egrep 'added:|removed:'
24 added: dirstate-v2 24 added: dirstate-v2
25 $ hg debugrequires | grep dirstate 25 $ hg debugrequires | grep dirstate
26 dirstate-v2 26 dirstate-v2
27 $ ls -1 .hg/dirstate* 27 $ ls -1 .hg/dirstate*
28 .hg/dirstate 28 .hg/dirstate
33 $ rm .hg/dirstate* 33 $ rm .hg/dirstate*
34 $ cp $TESTTMP/dirstate-v1-backup .hg/dirstate 34 $ cp $TESTTMP/dirstate-v1-backup .hg/dirstate
35 35
36 There should be no errors, but a v2 dirstate should be written back to disk 36 There should be no errors, but a v2 dirstate should be written back to disk
37 $ hg st 37 $ hg st
38 abort: dirstate-v2 parse error: when reading docket, Expected at least * bytes, got * (glob) (known-bad-output !)
39 [255]
40 $ ls -1 .hg/dirstate* 38 $ ls -1 .hg/dirstate*
41 .hg/dirstate 39 .hg/dirstate
42 .hg/dirstate.* (glob) (missing-correct-output !) 40 .hg/dirstate.* (glob)
43 41
42 Corrupt the dirstate to see how the errors show up to the user
43 $ echo "I ate your data" > .hg/dirstate
44
45 $ hg st
46 abort: working directory state appears damaged! (no-rhg !)
47 (falling back to dirstate-v1 from v2 also failed) (no-rhg !)
48 abort: Too little data for dirstate. (rhg !)
49 [255]