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.pre-read-file', + default=None, +) +coreconfigitem( + b'devel', + b'sync.dirstate.pre-read-file-timeout', + default=2, +) +coreconfigitem( + b'devel', b'strip-obsmarkers', default=True, ) diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py --- a/mercurial/dirstatemap.py +++ b/mercurial/dirstatemap.py @@ -10,6 +10,7 @@ from . import ( error, pathutil, policy, + testing, txnutil, util, ) @@ -276,7 +277,9 @@ class dirstatemap(_dirstatemapcommon): self._opener.join(self._filename) ) + testing.wait_on_cfg(self._ui, b'dirstate.pre-read-file') if self._use_dirstate_v2: + if not self.docket.uuid: return st = self._opener.read(self.docket.data_filename()) @@ -541,6 +544,7 @@ if rustmod is not None: self._opener.join(self._filename) ) + testing.wait_on_cfg(self._ui, b'dirstate.pre-read-file') if self._use_dirstate_v2: if self.docket.uuid: # TODO: use mmap when possible 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 @@ -10,6 +10,7 @@ use crate::lock::{try_with_lock_no_wait, use crate::manifest::{Manifest, Manifestlog}; use crate::revlog::filelog::Filelog; use crate::revlog::revlog::RevlogError; +use crate::utils::debug::debug_wait_for_file_or_print; use crate::utils::files::get_path_from_bytes; use crate::utils::hg_path::HgPath; use crate::utils::SliceExt; @@ -308,6 +309,10 @@ impl Repo { if self.has_dirstate_v2() { self.read_docket_and_data_file() } else { + debug_wait_for_file_or_print( + self.config(), + "dirstate.pre-read-file", + ); let dirstate_file_contents = self.dirstate_file_contents()?; if dirstate_file_contents.is_empty() { self.dirstate_parents.set(DirstateParents::NULL); @@ -324,6 +329,7 @@ impl Repo { fn read_docket_and_data_file( &self, ) -> Result { + debug_wait_for_file_or_print(self.config(), "dirstate.pre-read-file"); let dirstate_file_contents = self.dirstate_file_contents()?; if dirstate_file_contents.is_empty() { self.dirstate_parents.set(DirstateParents::NULL); diff --git a/rust/hg-core/src/utils/debug.rs b/rust/hg-core/src/utils/debug.rs --- a/rust/hg-core/src/utils/debug.rs +++ b/rust/hg-core/src/utils/debug.rs @@ -79,3 +79,9 @@ pub fn debug_wait_for_file( Ok(()) } } + +pub fn debug_wait_for_file_or_print(config: &Config, config_option: &str) { + if let Err(e) = debug_wait_for_file(&config, config_option) { + eprintln!("{e}"); + }; +}