changeset 50234:2be6d5782728 stable

dirstate: add a synchronisation point in the middle of the read This will be useful to test some more race conditions around dirstate.
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 13 Dec 2022 14:51:36 +0100
parents cf0d7cd6a6fa
children 385977432227
files mercurial/configitems.py mercurial/dirstatemap.py rust/hg-core/src/repo.rs
diffstat 3 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.py	Sun Feb 26 16:27:50 2023 +0100
+++ b/mercurial/configitems.py	Tue Dec 13 14:51:36 2022 +0100
@@ -704,6 +704,16 @@
 )
 coreconfigitem(
     b'devel',
+    b'sync.dirstate.post-docket-read-file',
+    default=None,
+)
+coreconfigitem(
+    b'devel',
+    b'sync.dirstate.post-docket-read-file-timeout',
+    default=2,
+)
+coreconfigitem(
+    b'devel',
     b'sync.dirstate.pre-read-file',
     default=None,
 )
--- a/mercurial/dirstatemap.py	Sun Feb 26 16:27:50 2023 +0100
+++ b/mercurial/dirstatemap.py	Tue Dec 13 14:51:36 2022 +0100
@@ -282,6 +282,7 @@
 
             if not self.docket.uuid:
                 return
+            testing.wait_on_cfg(self._ui, b'dirstate.post-docket-read-file')
             st = self._opener.read(self.docket.data_filename())
         else:
             st = self._readdirstatefile()
@@ -547,6 +548,9 @@
             testing.wait_on_cfg(self._ui, b'dirstate.pre-read-file')
             if self._use_dirstate_v2:
                 if self.docket.uuid:
+                    testing.wait_on_cfg(
+                        self._ui, b'dirstate.post-docket-read-file'
+                    )
                     # TODO: use mmap when possible
                     data = self._opener.read(self.docket.data_filename())
                 else:
--- a/rust/hg-core/src/repo.rs	Sun Feb 26 16:27:50 2023 +0100
+++ b/rust/hg-core/src/repo.rs	Tue Dec 13 14:51:36 2022 +0100
@@ -339,6 +339,10 @@
         let docket = crate::dirstate_tree::on_disk::read_docket(
             &dirstate_file_contents,
         )?;
+        debug_wait_for_file_or_print(
+            self.config(),
+            "dirstate.post-docket-read-file",
+        );
         self.dirstate_parents.set(docket.parents());
         self.dirstate_data_file_uuid
             .set(Some(docket.uuid.to_owned()));