##// END OF EJS Templates
rhg: add debugrhgsparse command to help figure out bugs in rhg
Raphaël Gomès -
r50379:85f5d11c default
parent child Browse files
Show More
@@ -0,0 +1,43 b''
1 use std::os::unix::prelude::OsStrExt;
2
3 use crate::error::CommandError;
4 use clap::SubCommand;
5 use hg::{self, utils::hg_path::HgPath};
6
7 pub const HELP_TEXT: &str = "";
8
9 pub fn args() -> clap::App<'static, 'static> {
10 SubCommand::with_name("debugrhgsparse")
11 .arg(
12 clap::Arg::with_name("files")
13 .required(true)
14 .multiple(true)
15 .empty_values(false)
16 .value_name("FILES")
17 .help("Files to check against sparse profile"),
18 )
19 .about(HELP_TEXT)
20 }
21
22 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
23 let repo = invocation.repo?;
24
25 let (matcher, _warnings) = hg::sparse::matcher(&repo).unwrap();
26 let files = invocation.subcommand_args.values_of_os("files");
27 if let Some(files) = files {
28 for file in files {
29 invocation.ui.write_stdout(b"matches: ")?;
30 invocation.ui.write_stdout(
31 if matcher.matches(HgPath::new(file.as_bytes())) {
32 b"yes"
33 } else {
34 b"no"
35 },
36 )?;
37 invocation.ui.write_stdout(b" | file: ")?;
38 invocation.ui.write_stdout(file.as_bytes())?;
39 invocation.ui.write_stdout(b"\n")?;
40 }
41 }
42 Ok(())
43 }
@@ -546,6 +546,7 b' subcommands! {'
546 debugdata
546 debugdata
547 debugrequirements
547 debugrequirements
548 debugignorerhg
548 debugignorerhg
549 debugrhgsparse
549 files
550 files
550 root
551 root
551 config
552 config
General Comments 0
You need to be logged in to leave comments. Login now