Mercurial > public > mercurial-scm > hg
view rust/rhg/src/commands/debugignorerhg.rs @ 48471:b005d07ded7d
rhg: Skip reading the contents of ambiguous files in some cases
If the size of the file in the working directory does not match the length of
the filelog data, we know its contents will be different and don?t need to
read it.
rhg still decodes the filelog revision, which is not needed in some cases.
Differential Revision: https://phab.mercurial-scm.org/D11910
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 14 Dec 2021 20:36:36 +0100 |
parents | 6d4daf51283c |
children | 363923bd51cd |
line wrap: on
line source
use crate::error::CommandError; use clap::SubCommand; 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::App<'static, 'static> { SubCommand::with_name("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().to_owned(), &mut |_pattern_bytes| (), ) .map_err(|e| StatusError::from(e))?; 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(()) }