debugignorerhg.rs
43 lines
| 1.2 KiB
| application/rls-services+xml
|
RustLexer
Arseniy Alekseyev
|
r49178 | use crate::error::CommandError; | ||
Raphaël Gomès
|
r53197 | use hg::dirstate::status::StatusError; | ||
Arseniy Alekseyev
|
r53250 | use hg::filepatterns::RegexCompleteness; | ||
use hg::matchers::get_ignore_matcher_pre; | ||||
Arseniy Alekseyev
|
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
|
r50534 | pub fn args() -> clap::Command { | ||
clap::command!("debugignorerhg").about(HELP_TEXT) | ||||
Arseniy Alekseyev
|
r49178 | } | ||
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { | ||||
let repo = invocation.repo?; | ||||
let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO hardcoded | ||||
Arseniy Alekseyev
|
r53250 | let (ignore_matcher, warnings) = get_ignore_matcher_pre( | ||
Arseniy Alekseyev
|
r49178 | vec![ignore_file], | ||
Raphaël Gomès
|
r50809 | repo.working_directory_path(), | ||
Raphaël Gomès
|
r50453 | &mut |_source, _pattern_bytes| (), | ||
Arseniy Alekseyev
|
r49178 | ) | ||
Raphaël Gomès
|
r50809 | .map_err(StatusError::from)?; | ||
Arseniy Alekseyev
|
r49178 | |||
Arseniy Alekseyev
|
r53250 | let ignore_matcher = ignore_matcher | ||
.build_debug_matcher(RegexComprehensiveness::Comprehensive) | ||||
.map_err(StatusError::from)?; | ||||
Arseniy Alekseyev
|
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(()) | ||||
} | ||||