# HG changeset patch # User Raphaël Gomès # Date 1658237829 -7200 # Node ID 85f5d11c77ddb25132782c678eb4af986744051a # Parent b18e877ea304974d40400551ddd91b9ca54cf893 rhg: add debugrhgsparse command to help figure out bugs in rhg diff -r b18e877ea304 -r 85f5d11c77dd rust/rhg/src/commands/debugrhgsparse.rs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rust/rhg/src/commands/debugrhgsparse.rs Tue Jul 19 15:37:09 2022 +0200 @@ -0,0 +1,43 @@ +use std::os::unix::prelude::OsStrExt; + +use crate::error::CommandError; +use clap::SubCommand; +use hg::{self, utils::hg_path::HgPath}; + +pub const HELP_TEXT: &str = ""; + +pub fn args() -> clap::App<'static, 'static> { + SubCommand::with_name("debugrhgsparse") + .arg( + clap::Arg::with_name("files") + .required(true) + .multiple(true) + .empty_values(false) + .value_name("FILES") + .help("Files to check against sparse profile"), + ) + .about(HELP_TEXT) +} + +pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { + let repo = invocation.repo?; + + let (matcher, _warnings) = hg::sparse::matcher(&repo).unwrap(); + let files = invocation.subcommand_args.values_of_os("files"); + if let Some(files) = files { + for file in files { + invocation.ui.write_stdout(b"matches: ")?; + invocation.ui.write_stdout( + if matcher.matches(HgPath::new(file.as_bytes())) { + b"yes" + } else { + b"no" + }, + )?; + invocation.ui.write_stdout(b" | file: ")?; + invocation.ui.write_stdout(file.as_bytes())?; + invocation.ui.write_stdout(b"\n")?; + } + } + Ok(()) +} diff -r b18e877ea304 -r 85f5d11c77dd rust/rhg/src/main.rs --- a/rust/rhg/src/main.rs Tue Jul 26 17:33:34 2022 +0200 +++ b/rust/rhg/src/main.rs Tue Jul 19 15:37:09 2022 +0200 @@ -546,6 +546,7 @@ debugdata debugrequirements debugignorerhg + debugrhgsparse files root config