Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/repo.rs @ 50228:fc8e37c380d3 stable
dirstate: add a synchronisation point before doing a full dirstate read
This will be useful to test some race conditions around the dirstate.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 25 Feb 2023 01:07:44 +0100 |
parents | cbd4c9234e25 |
children | 2be6d5782728 |
comparison
equal
deleted
inserted
replaced
50227:cbd4c9234e25 | 50228:fc8e37c380d3 |
---|---|
8 use crate::errors::{HgError, IoResultExt}; | 8 use crate::errors::{HgError, IoResultExt}; |
9 use crate::lock::{try_with_lock_no_wait, LockError}; | 9 use crate::lock::{try_with_lock_no_wait, LockError}; |
10 use crate::manifest::{Manifest, Manifestlog}; | 10 use crate::manifest::{Manifest, Manifestlog}; |
11 use crate::revlog::filelog::Filelog; | 11 use crate::revlog::filelog::Filelog; |
12 use crate::revlog::revlog::RevlogError; | 12 use crate::revlog::revlog::RevlogError; |
13 use crate::utils::debug::debug_wait_for_file_or_print; | |
13 use crate::utils::files::get_path_from_bytes; | 14 use crate::utils::files::get_path_from_bytes; |
14 use crate::utils::hg_path::HgPath; | 15 use crate::utils::hg_path::HgPath; |
15 use crate::utils::SliceExt; | 16 use crate::utils::SliceExt; |
16 use crate::vfs::{is_dir, is_file, Vfs}; | 17 use crate::vfs::{is_dir, is_file, Vfs}; |
17 use crate::{requirements, NodePrefix}; | 18 use crate::{requirements, NodePrefix}; |
306 | 307 |
307 fn new_dirstate_map(&self) -> Result<OwningDirstateMap, DirstateError> { | 308 fn new_dirstate_map(&self) -> Result<OwningDirstateMap, DirstateError> { |
308 if self.has_dirstate_v2() { | 309 if self.has_dirstate_v2() { |
309 self.read_docket_and_data_file() | 310 self.read_docket_and_data_file() |
310 } else { | 311 } else { |
312 debug_wait_for_file_or_print( | |
313 self.config(), | |
314 "dirstate.pre-read-file", | |
315 ); | |
311 let dirstate_file_contents = self.dirstate_file_contents()?; | 316 let dirstate_file_contents = self.dirstate_file_contents()?; |
312 if dirstate_file_contents.is_empty() { | 317 if dirstate_file_contents.is_empty() { |
313 self.dirstate_parents.set(DirstateParents::NULL); | 318 self.dirstate_parents.set(DirstateParents::NULL); |
314 Ok(OwningDirstateMap::new_empty(Vec::new())) | 319 Ok(OwningDirstateMap::new_empty(Vec::new())) |
315 } else { | 320 } else { |
322 } | 327 } |
323 | 328 |
324 fn read_docket_and_data_file( | 329 fn read_docket_and_data_file( |
325 &self, | 330 &self, |
326 ) -> Result<OwningDirstateMap, DirstateError> { | 331 ) -> Result<OwningDirstateMap, DirstateError> { |
332 debug_wait_for_file_or_print(self.config(), "dirstate.pre-read-file"); | |
327 let dirstate_file_contents = self.dirstate_file_contents()?; | 333 let dirstate_file_contents = self.dirstate_file_contents()?; |
328 if dirstate_file_contents.is_empty() { | 334 if dirstate_file_contents.is_empty() { |
329 self.dirstate_parents.set(DirstateParents::NULL); | 335 self.dirstate_parents.set(DirstateParents::NULL); |
330 self.dirstate_data_file_uuid.set(None); | 336 self.dirstate_data_file_uuid.set(None); |
331 return Ok(OwningDirstateMap::new_empty(Vec::new())); | 337 return Ok(OwningDirstateMap::new_empty(Vec::new())); |