comparison rust/rhg/src/commands/status.rs @ 50215:ae61851e6fe2 stable

dirstate: add a way to test races happening during status We add the `devel.sync.status.pre-dirstate-write-file` config option to easily test what happens when other operations happen during the window where `hg status` is done working but has not updated the cache on disk yet. We introduce the framework for testing such races too, actual tests will be added in the next changesets. For now the test is only checking dirstate-v1. We will extend the test coverage later too. Check test documentation for details. Code change from Raphaël Gomès <rgomes@octobus.net> Test change from Pierre-Yves David <pierre-yves.david@octobus.net>
author Raphaël Gomès <rgomes@octobus.net>, Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 28 Feb 2023 15:25:47 +0100
parents baa4e2c93642
children 53ca3e3bc013
comparison
equal deleted inserted replaced
50214:8e0d823ef182 50215:ae61851e6fe2
17 use hg::errors::{HgError, IoResultExt}; 17 use hg::errors::{HgError, IoResultExt};
18 use hg::lock::LockError; 18 use hg::lock::LockError;
19 use hg::manifest::Manifest; 19 use hg::manifest::Manifest;
20 use hg::matchers::{AlwaysMatcher, IntersectionMatcher}; 20 use hg::matchers::{AlwaysMatcher, IntersectionMatcher};
21 use hg::repo::Repo; 21 use hg::repo::Repo;
22 use hg::utils::debug::debug_wait_for_file;
22 use hg::utils::files::get_bytes_from_os_string; 23 use hg::utils::files::get_bytes_from_os_string;
23 use hg::utils::files::get_bytes_from_path; 24 use hg::utils::files::get_bytes_from_path;
24 use hg::utils::files::get_path_from_bytes; 25 use hg::utils::files::get_path_from_bytes;
25 use hg::utils::hg_path::{hg_path_to_path_buf, HgPath}; 26 use hg::utils::hg_path::{hg_path_to_path_buf, HgPath};
26 use hg::DirstateStatus; 27 use hg::DirstateStatus;
407 ignore_files(repo, config), 408 ignore_files(repo, config),
408 options, 409 options,
409 after_status, 410 after_status,
410 )?; 411 )?;
411 412
413 // Development config option to test write races
414 if let Err(e) =
415 debug_wait_for_file(&config, "status.pre-dirstate-write-file")
416 {
417 ui.write_stderr(e.as_bytes()).ok();
418 }
419
412 if (fixup.is_empty() || filesystem_time_at_status_start.is_none()) 420 if (fixup.is_empty() || filesystem_time_at_status_start.is_none())
413 && !dirstate_write_needed 421 && !dirstate_write_needed
414 { 422 {
415 // Nothing to update 423 // Nothing to update
416 return Ok(()); 424 return Ok(());