diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -167,6 +167,7 @@ class _dirstatemapcommon:
         return fp
 
     def _readdirstatefile(self, size: int = -1) -> bytes:
+        testing.wait_on_cfg(self._ui, b'dirstate.pre-read-file')
         try:
             with self._opendirstatefile() as fp:
                 return fp.read(size)
@@ -176,6 +177,7 @@ class _dirstatemapcommon:
 
     @property
     def docket(self) -> "docketmod.DirstateDocket":
+        testing.wait_on_cfg(self._ui, b'dirstate.pre-read-file')
         if not self._docket:
             if not self._use_dirstate_v2:
                 raise error.ProgrammingError(
diff --git a/tests/test-dirstate-read-race.t b/tests/test-dirstate-read-race.t
--- a/tests/test-dirstate-read-race.t
+++ b/tests/test-dirstate-read-race.t
@@ -167,23 +167,7 @@ The file should in a "added" state
 
 The status process should return a consistent result and not crash.
 
-#if dirstate-v1
-  $ cat $TESTTMP/status-race-lock.out
-  A dir/n
-  A dir/o
-  R dir/nested/m
-  ? p
-  ? q
-#else
-#if rhg pre-some-read dirstate-v2-append
-  $ cat $TESTTMP/status-race-lock.out
-  A dir/o
-  R dir/nested/m
-  ? dir/n
-  ? p
-  ? q
-#else
-#if rust no-rhg dirstate-v2-append
+#if rust dirstate-v2-append pre-some-read
   $ cat $TESTTMP/status-race-lock.out
   A dir/o
   R dir/nested/m
@@ -198,8 +182,6 @@ The status process should return a consi
   ? p
   ? q
 #endif
-#endif
-#endif
   $ cat $TESTTMP/status-race-lock.log
 
 final cleanup
@@ -249,30 +231,19 @@ commit was created, and status is now cl
 
 The status process should return a consistent result and not crash.
 
-#if no-rhg
+#if dirstate-v1
+  $ cat $TESTTMP/status-race-lock.out
+  ? dir/n
+  ? p
+  ? q
+#endif
+#if dirstate-v2
   $ cat $TESTTMP/status-race-lock.out
   A dir/o
   R dir/nested/m
   ? dir/n
   ? p
   ? q
-  $ cat $TESTTMP/status-race-lock.log
-#else
-#if pre-some-read dirstate-v2-append
-  $ cat $TESTTMP/status-race-lock.out
-  A dir/o
-  R dir/nested/m
-  ? dir/n
-  ? p
-  ? q
-  $ cat $TESTTMP/status-race-lock.log
-#else
-  $ cat $TESTTMP/status-race-lock.out
-  ? dir/n
-  ? p
-  ? q
-  $ cat $TESTTMP/status-race-lock.log
-#endif
 #endif
 
 final cleanup
@@ -323,21 +294,7 @@ do an update
 
 The status process should return a consistent result and not crash.
 
-#if rhg dirstate-v2-append pre-some-read
-  $ cat $TESTTMP/status-race-lock.out
-  A dir/o
-  R dir/nested/m
-  ! dir/i
-  ! dir/j
-  ! dir/nested/h
-  ! dir2/k
-  ! dir2/l
-  ! g
-  ? dir/n
-  ? p
-  ? q
-#else
-#if rust no-rhg dirstate-v2-append
+#if rust dirstate-v2-append pre-some-read
   $ cat $TESTTMP/status-race-lock.out
   A dir/o
   R dir/nested/m
@@ -357,7 +314,6 @@ The status process should return a consi
   ? p
   ? q
 #endif
-#endif
   $ cat $TESTTMP/status-race-lock.log
 
 final cleanup