diff --git a/rust/rhg/src/commands/debugignorerhg.rs b/rust/rhg/src/commands/debugignorerhg.rs --- a/rust/rhg/src/commands/debugignorerhg.rs +++ b/rust/rhg/src/commands/debugignorerhg.rs @@ -1,4 +1,5 @@ use crate::error::CommandError; +use clap::Arg; use hg::dirstate::status::StatusError; use hg::filepatterns::RegexCompleteness; use hg::matchers::get_ignore_matcher_pre; @@ -13,13 +14,22 @@ Some options might be missing, check the "; pub fn args() -> clap::Command { - clap::command!("debugignorerhg").about(HELP_TEXT) + 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) } pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { let repo = invocation.repo?; + let args = invocation.subcommand_args; let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO hardcoded + let all_patterns = args.get_flag("all-patterns"); let (ignore_matcher, warnings) = get_ignore_matcher_pre( vec![ignore_file], @@ -28,8 +38,13 @@ pub fn run(invocation: &crate::CliInvoca ) .map_err(StatusError::from)?; + let regex_config = if all_patterns { + RegexCompleteness::Complete + } else { + RegexCompleteness::ExcludeExactFiles + }; let ignore_matcher = ignore_matcher - .build_debug_matcher(RegexComprehensiveness::Comprehensive) + .build_debug_matcher(regex_config) .map_err(StatusError::from)?; if !warnings.is_empty() { diff --git a/tests/test-hgignore.t b/tests/test-hgignore.t --- a/tests/test-hgignore.t +++ b/tests/test-hgignore.t @@ -16,6 +16,11 @@ debugignore with no hgignore should be d $ hg debugignore +#if rhg + $ hg debugignorerhg + +#endif + Issue562: .hgignore requires newline at end: $ touch foo @@ -77,6 +82,11 @@ regexp with flag is the first one $ hg debugignore +#if rhg + $ hg debugignorerhg + (?i:.*\.O$)|.*.hgignore +#endif + regex with flag is not the first one $ echo 're:.hgignore' > .hgignore @@ -88,6 +98,11 @@ regex with flag is not the first one $ hg debugignore +#if rhg + $ hg debugignorerhg + .*.hgignore|(?i:.*\.O$) +#endif + flag in a pattern should affect that pattern only $ echo 're:(?i)\.O$' > .hgignore @@ -100,6 +115,11 @@ flag in a pattern should affect that pat $ hg debugignore +#if rhg + $ hg debugignorerhg + (?i:.*\.O$)|.*.HGIGNORE +#endif + $ echo 're:.HGIGNORE' > .hgignore $ echo 're:(?i)\.O$' >> .hgignore $ hg status @@ -110,6 +130,11 @@ flag in a pattern should affect that pat $ hg debugignore +#if rhg + $ hg debugignorerhg + .*.HGIGNORE|(?i:.*\.O$) +#endif + Check that '^' after flag is properly detected. $ echo 're:(?i)^[^a].*\.O$' > .hgignore @@ -123,6 +148,11 @@ Check that '^' after flag is properly de $ hg debugignore +#if rhg + $ hg debugignorerhg + (?i:^[^a].*\.O$)|.*.HGIGNORE +#endif + $ echo 're:.HGIGNORE' > .hgignore $ echo 're:(?i)^[^a].*\.O$' >> .hgignore $ hg status @@ -134,6 +164,10 @@ Check that '^' after flag is properly de $ hg debugignore +#if rhg + $ hg debugignorerhg + .*.HGIGNORE|(?i:^[^a].*\.O$) +#endif further testing --------------- @@ -317,6 +351,22 @@ Test relative ignore path (issue4473): ? a.o ? dir/c.o + $ echo "rootglob:dir/b.o" > .hgignore + $ hg status + A dir/b.o + ? .hgignore + ? a.c + ? a.o + ? dir/c.o + ? syntax +#if rhg + $ hg debugignorerhg -a + dir/b\.o(?:/|$) + + $ hg debugignorerhg + +#endif + $ echo "relglob:*" > .hgignore $ hg status A dir/b.o @@ -328,6 +378,11 @@ Test relative ignore path (issue4473): $ hg debugignore +#if rhg + $ hg debugignorerhg + .*(?:/|$) +#endif + $ hg debugignore b.o b.o is ignored (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: '*') (glob)