##// END OF EJS Templates
rust-pyo3: intermediate ProxyIndex extraction...
rust-pyo3: intermediate ProxyIndex extraction Retrieving the `UnsafePyLeaked` without borrowing it will be necessary for the upcoming classes that need to store an inner object derived from it.

File last commit:

r53251:ff19ddb2 default
r53424:64a61804 default
Show More
debugignorerhg.rs
58 lines | 1.7 KiB | application/rls-services+xml | RustLexer
/ rust / rhg / src / commands / debugignorerhg.rs
Arseniy Alekseyev
rhg: implement the debugignorerhg subcommand...
r49178 use crate::error::CommandError;
Arseniy Alekseyev
rust-ignore: add some tests of `debugignorerhg`, add flag -a to control output...
r53251 use clap::Arg;
Raphaël Gomès
rust-lib: only export very common types to the top of the crate...
r53197 use hg::dirstate::status::StatusError;
Arseniy Alekseyev
rust-ignore: make `debugignorerhg` command show a full regex, with exact files
r53250 use hg::filepatterns::RegexCompleteness;
use hg::matchers::get_ignore_matcher_pre;
Arseniy Alekseyev
rhg: implement the debugignorerhg subcommand...
r49178 use log::warn;
pub const HELP_TEXT: &str = "
Show effective hgignore patterns used by rhg.
This is a pure Rust version of `hg debugignore`.
Some options might be missing, check the list below.
";
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 pub fn args() -> clap::Command {
Arseniy Alekseyev
rust-ignore: add some tests of `debugignorerhg`, add flag -a to control output...
r53251 clap::command!("debugignorerhg")
.arg(
Arg::new("all-patterns")
.help("include all patterns, including ones for exact file matches")
.short('a')
.action(clap::ArgAction::SetTrue)
.long("all-patterns"),
).about(HELP_TEXT)
Arseniy Alekseyev
rhg: implement the debugignorerhg subcommand...
r49178 }
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let repo = invocation.repo?;
Arseniy Alekseyev
rust-ignore: add some tests of `debugignorerhg`, add flag -a to control output...
r53251 let args = invocation.subcommand_args;
Arseniy Alekseyev
rhg: implement the debugignorerhg subcommand...
r49178
let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO hardcoded
Arseniy Alekseyev
rust-ignore: add some tests of `debugignorerhg`, add flag -a to control output...
r53251 let all_patterns = args.get_flag("all-patterns");
Arseniy Alekseyev
rhg: implement the debugignorerhg subcommand...
r49178
Arseniy Alekseyev
rust-ignore: make `debugignorerhg` command show a full regex, with exact files
r53250 let (ignore_matcher, warnings) = get_ignore_matcher_pre(
Arseniy Alekseyev
rhg: implement the debugignorerhg subcommand...
r49178 vec![ignore_file],
Raphaël Gomès
rust: run `cargo clippy`...
r50809 repo.working_directory_path(),
Raphaël Gomès
dirstate-v2: hash the source of the ignore patterns as well...
r50453 &mut |_source, _pattern_bytes| (),
Arseniy Alekseyev
rhg: implement the debugignorerhg subcommand...
r49178 )
Raphaël Gomès
rust: run `cargo clippy`...
r50809 .map_err(StatusError::from)?;
Arseniy Alekseyev
rhg: implement the debugignorerhg subcommand...
r49178
Arseniy Alekseyev
rust-ignore: add some tests of `debugignorerhg`, add flag -a to control output...
r53251 let regex_config = if all_patterns {
RegexCompleteness::Complete
} else {
RegexCompleteness::ExcludeExactFiles
};
Arseniy Alekseyev
rust-ignore: make `debugignorerhg` command show a full regex, with exact files
r53250 let ignore_matcher = ignore_matcher
Arseniy Alekseyev
rust-ignore: add some tests of `debugignorerhg`, add flag -a to control output...
r53251 .build_debug_matcher(regex_config)
Arseniy Alekseyev
rust-ignore: make `debugignorerhg` command show a full regex, with exact files
r53250 .map_err(StatusError::from)?;
Arseniy Alekseyev
rhg: implement the debugignorerhg subcommand...
r49178 if !warnings.is_empty() {
warn!("Pattern warnings: {:?}", &warnings);
}
let patterns = ignore_matcher.debug_get_patterns();
invocation.ui.write_stdout(patterns)?;
invocation.ui.write_stdout(b"\n")?;
Ok(())
}