equal
deleted
inserted
replaced
|
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 } |