Patchwork D10718: dirstate-v2: Update the expected output of some tests for new requirement

login
register
mail settings
Submitter phabricator
Date May 17, 2021, 10:12 a.m.
Message ID <differential-rev-PHID-DREV-xlluxbtpsamqzdituzgv-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49042/
State Superseded
Headers show

Comments

phabricator - May 17, 2021, 10:12 a.m.
SimonSapin created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Fix most test failures (except in test-narrow-debugrebuilddirstate.t and
  test-upgrade-repo.t) caused by the new entry in config or in .hg/requires
  when running `run-tests.py --extra-config-opt format.exp-dirstate-v2=1`
  
  There is no CI so far for this configuration.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10718

AFFECTED FILES
  mercurial/localrepo.py
  tests/hghave.py
  tests/test-basic.t
  tests/test-clone-uncompressed.t
  tests/test-commandserver.t
  tests/test-config.t
  tests/test-init.t
  tests/test-lfconvert.t
  tests/test-lfs-largefiles.t
  tests/test-narrow-clone-no-ellipsis.t
  tests/test-narrow-clone-stream.t
  tests/test-narrow-clone.t
  tests/test-narrow-sparse.t
  tests/test-persistent-nodemap.t
  tests/test-phases.t
  tests/test-remotefilelog-clone-tree.t
  tests/test-remotefilelog-clone.t
  tests/test-remotefilelog-log.t
  tests/test-repo-compengines.t
  tests/test-requires.t
  tests/test-revlog-v2.t
  tests/test-share-safe.t
  tests/test-sparse-requirement.t
  tests/test-sqlitestore.t
  tests/test-stream-bundle-v2.t

CHANGE DETAILS




To: SimonSapin, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-stream-bundle-v2.t b/tests/test-stream-bundle-v2.t
--- a/tests/test-stream-bundle-v2.t
+++ b/tests/test-stream-bundle-v2.t
@@ -48,11 +48,13 @@ 
   Stream params: {}
   stream2 -- {bytecount: 1693, filecount: 11, requirements: dotencode%2Cfncache%2Cgeneraldelta%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (no-zstd !)
   stream2 -- {bytecount: 1693, filecount: 11, requirements: dotencode%2Cfncache%2Cgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (zstd no-rust !)
-  stream2 -- {bytecount: 1693, filecount: 11, requirements: dotencode%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (rust !)
+  stream2 -- {bytecount: 1693, filecount: 11, requirements: dotencode%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (rust no-dirstate-v2 !)
+  stream2 -- {bytecount: 1693, filecount: 11, requirements: dotencode%2Cexp-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore} (mandatory: True) (dirstate-v2 !)
   $ hg debugbundle --spec bundle.hg
   none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Crevlogv1%2Csparserevlog%2Cstore (no-zstd !)
   none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore (zstd no-rust !)
-  none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore (rust !)
+  none-v2;stream=v2;requirements%3Ddotencode%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore (rust no-dirstate-v2 !)
+  none-v2;stream=v2;requirements%3Ddotencode%2Cexp-dirstate-v2%2Cfncache%2Cgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog%2Cstore (dirstate-v2 !)
 
 Test that we can apply the bundle as a stream clone bundle
 
diff --git a/tests/test-sqlitestore.t b/tests/test-sqlitestore.t
--- a/tests/test-sqlitestore.t
+++ b/tests/test-sqlitestore.t
@@ -15,6 +15,7 @@ 
   $ hg init empty-no-sqlite
   $ cat empty-no-sqlite/.hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
@@ -28,6 +29,7 @@ 
   $ hg --config storage.new-repo-backend=sqlite init empty-sqlite
   $ cat empty-sqlite/.hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-sqlite-001
   exp-sqlite-comp-001=zstd (zstd !)
   exp-sqlite-comp-001=$BUNDLE2_COMPRESSIONS$ (no-zstd !)
@@ -49,6 +51,7 @@ 
   $ hg --config storage.sqlite.compression=zlib init empty-zlib
   $ cat empty-zlib/.hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-sqlite-001
   exp-sqlite-comp-001=$BUNDLE2_COMPRESSIONS$
   fncache
@@ -64,6 +67,7 @@ 
   $ hg --config storage.sqlite.compression=none init empty-none
   $ cat empty-none/.hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-sqlite-001
   exp-sqlite-comp-001=none
   fncache
diff --git a/tests/test-sparse-requirement.t b/tests/test-sparse-requirement.t
--- a/tests/test-sparse-requirement.t
+++ b/tests/test-sparse-requirement.t
@@ -18,6 +18,7 @@ 
 
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
@@ -37,6 +38,7 @@ 
 
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-sparse
   fncache
   generaldelta
@@ -59,6 +61,7 @@ 
 
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t
--- a/tests/test-share-safe.t
+++ b/tests/test-share-safe.t
@@ -12,8 +12,11 @@ 
   > revlog-compression=zlib
   > # we want to be able to enable it later
   > use-persistent-nodemap=no
+  > exp-dirstate-v2=no
   > EOF
 
+TODO: add tests with share and dirstate-v2
+
 prepare source repo
 
   $ hg init source
diff --git a/tests/test-revlog-v2.t b/tests/test-revlog-v2.t
--- a/tests/test-revlog-v2.t
+++ b/tests/test-revlog-v2.t
@@ -22,6 +22,7 @@ 
   $ cd empty-repo
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-revlogv2.2
   fncache
   persistent-nodemap (rust !)
diff --git a/tests/test-requires.t b/tests/test-requires.t
--- a/tests/test-requires.t
+++ b/tests/test-requires.t
@@ -50,6 +50,7 @@ 
   > EOF
   $ hg -R supported debugrequirements
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   featuresetup-test
   fncache
   generaldelta
diff --git a/tests/test-repo-compengines.t b/tests/test-repo-compengines.t
--- a/tests/test-repo-compengines.t
+++ b/tests/test-repo-compengines.t
@@ -11,6 +11,7 @@ 
   $ cd default
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
@@ -60,6 +61,7 @@ 
 
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
@@ -79,6 +81,7 @@ 
   $ cd zstd
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
@@ -183,6 +186,7 @@ 
   $ cat none-compression/.hg/requires
   dotencode
   exp-compression-none
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
diff --git a/tests/test-remotefilelog-log.t b/tests/test-remotefilelog-log.t
--- a/tests/test-remotefilelog-log.t
+++ b/tests/test-remotefilelog-log.t
@@ -27,6 +27,7 @@ 
   $ cd shallow
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-remotefilelog-repo-req-1
   fncache
   generaldelta
diff --git a/tests/test-remotefilelog-clone.t b/tests/test-remotefilelog-clone.t
--- a/tests/test-remotefilelog-clone.t
+++ b/tests/test-remotefilelog-clone.t
@@ -24,6 +24,7 @@ 
   $ cd shallow
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-remotefilelog-repo-req-1
   fncache
   generaldelta
@@ -60,6 +61,7 @@ 
   $ cd shallow2
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-remotefilelog-repo-req-1
   fncache
   generaldelta
@@ -111,6 +113,7 @@ 
   $ ls shallow3/.hg/store/data
   $ cat shallow3/.hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-remotefilelog-repo-req-1
   fncache
   generaldelta
diff --git a/tests/test-remotefilelog-clone-tree.t b/tests/test-remotefilelog-clone-tree.t
--- a/tests/test-remotefilelog-clone-tree.t
+++ b/tests/test-remotefilelog-clone-tree.t
@@ -27,6 +27,7 @@ 
   $ cd shallow
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-remotefilelog-repo-req-1
   fncache
   generaldelta
@@ -70,6 +71,7 @@ 
   $ cd shallow2
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-remotefilelog-repo-req-1
   fncache
   generaldelta
@@ -113,6 +115,7 @@ 
   $ ls shallow3/.hg/store/data
   $ cat shallow3/.hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   exp-remotefilelog-repo-req-1
   fncache
   generaldelta
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -884,6 +884,7 @@ 
   $ cd no-internal-phase
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
@@ -912,6 +913,7 @@ 
   $ cd internal-phase
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   internal-phase
diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -591,8 +591,9 @@ 
   upgrade will perform the following actions:
   
   requirements
-     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-zstd !)
-     preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, revlogv1, sparserevlog, store (zstd !)
+     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-zstd no-dirstate-v2 !)
+     preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, revlogv1, sparserevlog, store (zstd no-dirstate-v2 !)
+     preserved: dotencode, exp-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, sparserevlog, store (zstd dirstate-v2 !)
      removed: persistent-nodemap
   
   processed revlogs:
@@ -638,8 +639,9 @@ 
   upgrade will perform the following actions:
   
   requirements
-     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-zstd !)
-     preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, revlogv1, sparserevlog, store (zstd !)
+     preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store (no-zstd no-dirstate-v2 !)
+     preserved: dotencode, fncache, generaldelta, revlog-compression-zstd, revlogv1, sparserevlog, store (zstd no-dirstate-v2 !)
+     preserved: dotencode, exp-dirstate-v2, fncache, generaldelta, revlog-compression-zstd, revlogv1, sparserevlog, store (zstd dirstate-v2 !)
      added: persistent-nodemap
   
   persistent-nodemap
@@ -678,8 +680,9 @@ 
   upgrade will perform the following actions:
   
   requirements
-     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (no-zstd !)
-     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, revlogv1, sparserevlog, store (zstd !)
+     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlogv1, sparserevlog, store (no-zstd no-dirstate-v2 !)
+     preserved: dotencode, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, revlogv1, sparserevlog, store (zstd no-dirstate-v2 !)
+     preserved: dotencode, exp-dirstate-v2, fncache, generaldelta, persistent-nodemap, revlog-compression-zstd, revlogv1, sparserevlog, store (zstd dirstate-v2 !)
   
   optimisations: re-delta-all
   
diff --git a/tests/test-narrow-sparse.t b/tests/test-narrow-sparse.t
--- a/tests/test-narrow-sparse.t
+++ b/tests/test-narrow-sparse.t
@@ -58,6 +58,7 @@ 
 
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   narrowhg-experimental
diff --git a/tests/test-narrow-clone.t b/tests/test-narrow-clone.t
--- a/tests/test-narrow-clone.t
+++ b/tests/test-narrow-clone.t
@@ -40,6 +40,7 @@ 
   $ cd narrow
   $ cat .hg/requires | grep -v generaldelta
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   narrowhg-experimental
   persistent-nodemap (rust !)
diff --git a/tests/test-narrow-clone-stream.t b/tests/test-narrow-clone-stream.t
--- a/tests/test-narrow-clone-stream.t
+++ b/tests/test-narrow-clone-stream.t
@@ -64,6 +64,7 @@ 
   $ cat .hg/requires
   dotencode (tree !)
   dotencode (flat-fncache !)
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache (tree !)
   fncache (flat-fncache !)
   generaldelta
diff --git a/tests/test-narrow-clone-no-ellipsis.t b/tests/test-narrow-clone-no-ellipsis.t
--- a/tests/test-narrow-clone-no-ellipsis.t
+++ b/tests/test-narrow-clone-no-ellipsis.t
@@ -24,6 +24,7 @@ 
   $ cd narrow
   $ cat .hg/requires | grep -v generaldelta
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   narrowhg-experimental
   persistent-nodemap (rust !)
diff --git a/tests/test-lfs-largefiles.t b/tests/test-lfs-largefiles.t
--- a/tests/test-lfs-largefiles.t
+++ b/tests/test-lfs-largefiles.t
@@ -290,6 +290,7 @@ 
 
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   lfs
diff --git a/tests/test-lfconvert.t b/tests/test-lfconvert.t
--- a/tests/test-lfconvert.t
+++ b/tests/test-lfconvert.t
@@ -96,6 +96,7 @@ 
 "lfconvert" adds 'largefiles' to .hg/requires.
   $ cat .hg/requires
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   largefiles
diff --git a/tests/test-init.t b/tests/test-init.t
--- a/tests/test-init.t
+++ b/tests/test-init.t
@@ -19,6 +19,7 @@ 
   store created
   00changelog.i created
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
@@ -60,6 +61,7 @@ 
 
   $ hg --config format.usestore=false init old
   $ checknewrepo old
+  exp-dirstate-v2 (dirstate-v2 !)
   generaldelta
   persistent-nodemap (rust !)
   revlog-compression-zstd (zstd !)
@@ -73,6 +75,7 @@ 
   $ checknewrepo old2
   store created
   00changelog.i created
+  exp-dirstate-v2 (dirstate-v2 !)
   generaldelta
   persistent-nodemap (rust !)
   revlog-compression-zstd (zstd !)
@@ -87,6 +90,7 @@ 
   $ checknewrepo old3
   store created
   00changelog.i created
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
@@ -103,6 +107,7 @@ 
   store created
   00changelog.i created
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   persistent-nodemap (rust !)
   revlog-compression-zstd (zstd !)
@@ -221,6 +226,7 @@ 
   store created
   00changelog.i created
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
@@ -243,6 +249,7 @@ 
   store created
   00changelog.i created
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
@@ -261,6 +268,7 @@ 
   store created
   00changelog.i created
   dotencode
+  exp-dirstate-v2 (dirstate-v2 !)
   fncache
   generaldelta
   persistent-nodemap (rust !)
diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -159,7 +159,7 @@ 
 
  true
 
-  $ hg config --config format.dotencode= format -Tjson
+  $ hg config --config format.dotencode= format.dotencode -Tjson
   [
    {
     "defaultvalue": true,
@@ -168,11 +168,11 @@ 
     "value": ""
    }
   ]
-  $ hg config --config format.dotencode= format -T'json(defaultvalue)'
+  $ hg config --config format.dotencode= format.dotencode -T'json(defaultvalue)'
   [
    {"defaultvalue": true}
   ]
-  $ hg config --config format.dotencode= format -T'{defaultvalue}\n'
+  $ hg config --config format.dotencode= format.dotencode -T'{defaultvalue}\n'
   True
 
  bytes
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -207,6 +207,7 @@ 
   devel.all-warnings=true
   devel.default-date=0 0
   extensions.fsmonitor= (fsmonitor !)
+  format.exp-dirstate-v2=1 (dirstate-v2 !)
   largefiles.usercache=$TESTTMP/.cache/largefiles
   lfs.usercache=$TESTTMP/.cache/lfs
   ui.slash=True
diff --git a/tests/test-clone-uncompressed.t b/tests/test-clone-uncompressed.t
--- a/tests/test-clone-uncompressed.t
+++ b/tests/test-clone-uncompressed.t
@@ -256,7 +256,7 @@ 
   00e0: 87 bf ce fe 56 67 92 67 2c 69 d1 ec 39 00 00 00 |....Vg.g,i..9...|
   00f0: 00 00 00 00 00 00 00 00 00 75 30 73 08 42 64 61 |.........u0s.Bda|
 #endif
-#if zstd rust
+#if zstd rust no-dirstate-v2
   $ f --size --hex --bytes 256 body
   body: size=109431
   0000: 04 6e 6f 6e 65 48 47 32 30 00 00 00 00 00 00 00 |.noneHG20.......|
@@ -276,6 +276,26 @@ 
   00e0: 00 00 00 00 00 01 ff ff ff ff ff ff ff ff 80 29 |...............)|
   00f0: 63 a0 49 d3 23 87 bf ce fe 56 67 92 67 2c 69 d1 |c.I.#....Vg.g,i.|
 #endif
+#if zstd dirstate-v2
+  $ f --size --hex --bytes 256 body
+  body: size=109449
+  0000: 04 6e 6f 6e 65 48 47 32 30 00 00 00 00 00 00 00 |.noneHG20.......|
+  0010: c0 07 53 54 52 45 41 4d 32 00 00 00 00 03 00 09 |..STREAM2.......|
+  0020: 05 09 04 0c 85 62 79 74 65 63 6f 75 6e 74 39 35 |.....bytecount95|
+  0030: 38 39 37 66 69 6c 65 63 6f 75 6e 74 31 30 33 30 |897filecount1030|
+  0040: 72 65 71 75 69 72 65 6d 65 6e 74 73 64 6f 74 65 |requirementsdote|
+  0050: 6e 63 6f 64 65 25 32 43 65 78 70 2d 64 69 72 73 |ncode%2Cexp-dirs|
+  0060: 74 61 74 65 2d 76 32 25 32 43 66 6e 63 61 63 68 |tate-v2%2Cfncach|
+  0070: 65 25 32 43 67 65 6e 65 72 61 6c 64 65 6c 74 61 |e%2Cgeneraldelta|
+  0080: 25 32 43 70 65 72 73 69 73 74 65 6e 74 2d 6e 6f |%2Cpersistent-no|
+  0090: 64 65 6d 61 70 25 32 43 72 65 76 6c 6f 67 2d 63 |demap%2Crevlog-c|
+  00a0: 6f 6d 70 72 65 73 73 69 6f 6e 2d 7a 73 74 64 25 |ompression-zstd%|
+  00b0: 32 43 72 65 76 6c 6f 67 76 31 25 32 43 73 70 61 |2Crevlogv1%2Cspa|
+  00c0: 72 73 65 72 65 76 6c 6f 67 25 32 43 73 74 6f 72 |rserevlog%2Cstor|
+  00d0: 65 00 00 80 00 73 08 42 64 61 74 61 2f 30 2e 69 |e....s.Bdata/0.i|
+  00e0: 00 03 00 01 00 00 00 00 00 00 00 02 00 00 00 01 |................|
+  00f0: 00 00 00 00 00 00 00 01 ff ff ff ff ff ff ff ff |................|
+#endif
 
 --uncompressed is an alias to --stream
 
diff --git a/tests/test-basic.t b/tests/test-basic.t
--- a/tests/test-basic.t
+++ b/tests/test-basic.t
@@ -5,6 +5,7 @@ 
   devel.all-warnings=true
   devel.default-date=0 0
   extensions.fsmonitor= (fsmonitor !)
+  format.exp-dirstate-v2=1 (dirstate-v2 !)
   largefiles.usercache=$TESTTMP/.cache/largefiles
   lfs.usercache=$TESTTMP/.cache/lfs
   ui.slash=True
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -1042,6 +1042,14 @@ 
     return 'fncache' in getrepofeatures()
 
 
+@check('dirstate-v2', 'using the v2 format of .hg/dirstate')
+def has_dirstate_v2():
+    # Keep this logic in sync with `newreporequirements()` in `mercurial/localrepo.py`
+    return has_rust() and matchoutput(
+        'hg config format.exp-dirstate-v2', b'(?i)1|yes|true|on|always'
+    )
+
+
 @check('sqlite', 'sqlite3 module and matching cli is available')
 def has_sqlite():
     try:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3518,6 +3518,7 @@ 
             requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
 
     # experimental config: format.exp-dirstate-v2
+    # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
     if ui.configbool(b'format', b'exp-dirstate-v2'):
         if dirstate.SUPPORTS_DIRSTATE_V2:
             requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)