changeset 50659:9e08cfbe77b1 stable

dirstate: add test showing dirstate version mismatch causes an error We should fall back to trying dirstate v1 when v2 fails to read.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 05 Jun 2023 17:29:52 +0200
parents 1e2c6cda2309
children bf16ef96defe
files tests/test-dirstate-version-fallback.t
diffstat 1 files changed, 43 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-dirstate-version-fallback.t	Mon Jun 05 17:29:52 2023 +0200
@@ -0,0 +1,43 @@
+  $ cat >> $HGRCPATH << EOF
+  > [storage]
+  > dirstate-v2.slow-path=allow
+  > EOF
+
+Set up a v1 repo
+
+  $ hg init repo
+  $ cd repo
+  $ echo a > a
+  $ hg add a
+  $ hg commit -m a
+  $ hg debugrequires | grep dirstate
+  [1]
+  $ ls -1 .hg/dirstate*
+  .hg/dirstate
+
+Copy v1 dirstate
+  $ cp .hg/dirstate $TESTTMP/dirstate-v1-backup
+
+Upgrade it to v2
+
+  $ hg debugupgraderepo -q --config format.use-dirstate-v2=1 --run | grep added
+     added: dirstate-v2
+  $ hg debugrequires | grep dirstate
+  dirstate-v2
+  $ ls -1 .hg/dirstate*
+  .hg/dirstate
+  .hg/dirstate.* (glob)
+
+Manually reset to dirstate v1 to simulate an incomplete dirstate-v2 upgrade
+
+  $ rm .hg/dirstate*
+  $ cp $TESTTMP/dirstate-v1-backup .hg/dirstate
+
+There should be no errors, but a v2 dirstate should be written back to disk
+  $ hg st
+  abort: dirstate-v2 parse error: when reading docket, Expected at least * bytes, got * (glob) (known-bad-output !)
+  [255]
+  $ ls -1 .hg/dirstate*
+  .hg/dirstate
+  .hg/dirstate.* (glob) (missing-correct-output !)
+