# HG changeset patch # User Raphaël Gomès # Date 2022-12-13 13:51:36 # Node ID 2be6d5782728efaa29cbfc1178a23e1a30e4dc01 # Parent cf0d7cd6a6fa5621887e8ea6df957530bcb94390 dirstate: add a synchronisation point in the middle of the read This will be useful to test some more race conditions around dirstate. diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -704,6 +704,16 @@ coreconfigitem( ) 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, ) diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py --- a/mercurial/dirstatemap.py +++ b/mercurial/dirstatemap.py @@ -282,6 +282,7 @@ class dirstatemap(_dirstatemapcommon): 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 @@ if rustmod is not None: 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: diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs --- a/rust/hg-core/src/repo.rs +++ b/rust/hg-core/src/repo.rs @@ -339,6 +339,10 @@ impl Repo { 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()));