Mercurial > public > mercurial-scm > hg
view rust/rhg/src/commands/debugdata.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 | 0199712c7a6d |
children | 37bc3edef76f |
line wrap: on
line source
use crate::error::CommandError; use clap::Arg; use clap::ArgGroup; use hg::operations::{debug_data, DebugDataKind}; use micro_timer::timed; pub const HELP_TEXT: &str = " Dump the contents of a data file revision "; pub fn args() -> clap::App<'static, 'static> { clap::SubCommand::with_name("debugdata") .arg( Arg::with_name("changelog") .help("open changelog") .short("-c") .long("--changelog"), ) .arg( Arg::with_name("manifest") .help("open manifest") .short("-m") .long("--manifest"), ) .group( ArgGroup::with_name("") .args(&["changelog", "manifest"]) .required(true), ) .arg( Arg::with_name("rev") .help("revision") .required(true) .value_name("REV"), ) .about(HELP_TEXT) } #[timed] pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { let args = invocation.subcommand_args; let rev = args .value_of("rev") .expect("rev should be a required argument"); let kind = match (args.is_present("changelog"), args.is_present("manifest")) { (true, false) => DebugDataKind::Changelog, (false, true) => DebugDataKind::Manifest, (true, true) => { unreachable!("Should not happen since options are exclusive") } (false, false) => { unreachable!("Should not happen since options are required") } }; let repo = invocation.repo?; if repo.has_narrow() { return Err(CommandError::unsupported( "support for ellipsis nodes is missing and repo has narrow enabled", )); } let data = debug_data(repo, rev, kind).map_err(|e| (e, rev))?; let mut stdout = invocation.ui.stdout_buffer(); stdout.write_all(&data)?; stdout.flush()?; Ok(()) }