##// END OF EJS Templates
typing: add type hints to argument checking functions in cmdutil...
typing: add type hints to argument checking functions in cmdutil These might be surprising, since they can take strings instead of bytes. The way `AnyStr` works is that it must be all bytes or all str for any given invocation. The wildcard here will be the `opts` that get passed in- if the type is unknown and defaults to `Any`, there's no enforcement that the dict key type matches the additional args. But a lot of uses should be using `**opts` from the command method, which has a str key. The uses of these methods in this module are now typed because their internals force a specific type, and it can't just be inferred from the caller.

File last commit:

r50809:58074252 default
r50987:ce60c8d4 default
Show More
debugignorerhg.rs
39 lines | 1.0 KiB | application/rls-services+xml | RustLexer
use crate::error::CommandError;
use hg;
use hg::matchers::get_ignore_matcher;
use hg::StatusError;
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.
";
pub fn args() -> clap::Command {
clap::command!("debugignorerhg").about(HELP_TEXT)
}
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let repo = invocation.repo?;
let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO hardcoded
let (ignore_matcher, warnings) = get_ignore_matcher(
vec![ignore_file],
repo.working_directory_path(),
&mut |_source, _pattern_bytes| (),
)
.map_err(StatusError::from)?;
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(())
}