Show More
@@ -1,4 +1,5 | |||
|
1 | 1 | use crate::error::CommandError; |
|
2 | use clap::Arg; | |
|
2 | 3 | use hg::dirstate::status::StatusError; |
|
3 | 4 | use hg::filepatterns::RegexCompleteness; |
|
4 | 5 | use hg::matchers::get_ignore_matcher_pre; |
@@ -13,13 +14,22 Some options might be missing, check the | |||
|
13 | 14 | "; |
|
14 | 15 | |
|
15 | 16 | pub fn args() -> clap::Command { |
|
16 |
clap::command!("debugignorerhg") |
|
|
17 | clap::command!("debugignorerhg") | |
|
18 | .arg( | |
|
19 | Arg::new("all-patterns") | |
|
20 | .help("include all patterns, including ones for exact file matches") | |
|
21 | .short('a') | |
|
22 | .action(clap::ArgAction::SetTrue) | |
|
23 | .long("all-patterns"), | |
|
24 | ).about(HELP_TEXT) | |
|
17 | 25 | } |
|
18 | 26 | |
|
19 | 27 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
|
20 | 28 | let repo = invocation.repo?; |
|
29 | let args = invocation.subcommand_args; | |
|
21 | 30 | |
|
22 | 31 | let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO hardcoded |
|
32 | let all_patterns = args.get_flag("all-patterns"); | |
|
23 | 33 | |
|
24 | 34 | let (ignore_matcher, warnings) = get_ignore_matcher_pre( |
|
25 | 35 | vec![ignore_file], |
@@ -28,8 +38,13 pub fn run(invocation: &crate::CliInvoca | |||
|
28 | 38 | ) |
|
29 | 39 | .map_err(StatusError::from)?; |
|
30 | 40 | |
|
41 | let regex_config = if all_patterns { | |
|
42 | RegexCompleteness::Complete | |
|
43 | } else { | |
|
44 | RegexCompleteness::ExcludeExactFiles | |
|
45 | }; | |
|
31 | 46 | let ignore_matcher = ignore_matcher |
|
32 |
.build_debug_matcher( |
|
|
47 | .build_debug_matcher(regex_config) | |
|
33 | 48 | .map_err(StatusError::from)?; |
|
34 | 49 | |
|
35 | 50 | if !warnings.is_empty() { |
@@ -16,6 +16,11 debugignore with no hgignore should be d | |||
|
16 | 16 | $ hg debugignore |
|
17 | 17 | <nevermatcher> |
|
18 | 18 | |
|
19 | #if rhg | |
|
20 | $ hg debugignorerhg | |
|
21 | ||
|
22 | #endif | |
|
23 | ||
|
19 | 24 | Issue562: .hgignore requires newline at end: |
|
20 | 25 | |
|
21 | 26 | $ touch foo |
@@ -77,6 +82,11 regexp with flag is the first one | |||
|
77 | 82 | $ hg debugignore |
|
78 | 83 | <includematcher includes='(?i:.*\\.O$)|.*.hgignore'> |
|
79 | 84 | |
|
85 | #if rhg | |
|
86 | $ hg debugignorerhg | |
|
87 | (?i:.*\.O$)|.*.hgignore | |
|
88 | #endif | |
|
89 | ||
|
80 | 90 | regex with flag is not the first one |
|
81 | 91 | |
|
82 | 92 | $ echo 're:.hgignore' > .hgignore |
@@ -88,6 +98,11 regex with flag is not the first one | |||
|
88 | 98 | $ hg debugignore |
|
89 | 99 | <includematcher includes='.*.hgignore|(?i:.*\\.O$)'> |
|
90 | 100 | |
|
101 | #if rhg | |
|
102 | $ hg debugignorerhg | |
|
103 | .*.hgignore|(?i:.*\.O$) | |
|
104 | #endif | |
|
105 | ||
|
91 | 106 | flag in a pattern should affect that pattern only |
|
92 | 107 | |
|
93 | 108 | $ echo 're:(?i)\.O$' > .hgignore |
@@ -100,6 +115,11 flag in a pattern should affect that pat | |||
|
100 | 115 | $ hg debugignore |
|
101 | 116 | <includematcher includes='(?i:.*\\.O$)|.*.HGIGNORE'> |
|
102 | 117 | |
|
118 | #if rhg | |
|
119 | $ hg debugignorerhg | |
|
120 | (?i:.*\.O$)|.*.HGIGNORE | |
|
121 | #endif | |
|
122 | ||
|
103 | 123 | $ echo 're:.HGIGNORE' > .hgignore |
|
104 | 124 | $ echo 're:(?i)\.O$' >> .hgignore |
|
105 | 125 | $ hg status |
@@ -110,6 +130,11 flag in a pattern should affect that pat | |||
|
110 | 130 | $ hg debugignore |
|
111 | 131 | <includematcher includes='.*.HGIGNORE|(?i:.*\\.O$)'> |
|
112 | 132 | |
|
133 | #if rhg | |
|
134 | $ hg debugignorerhg | |
|
135 | .*.HGIGNORE|(?i:.*\.O$) | |
|
136 | #endif | |
|
137 | ||
|
113 | 138 | Check that '^' after flag is properly detected. |
|
114 | 139 | |
|
115 | 140 | $ echo 're:(?i)^[^a].*\.O$' > .hgignore |
@@ -123,6 +148,11 Check that '^' after flag is properly de | |||
|
123 | 148 | $ hg debugignore |
|
124 | 149 | <includematcher includes='(?i:^[^a].*\\.O$)|.*.HGIGNORE'> |
|
125 | 150 | |
|
151 | #if rhg | |
|
152 | $ hg debugignorerhg | |
|
153 | (?i:^[^a].*\.O$)|.*.HGIGNORE | |
|
154 | #endif | |
|
155 | ||
|
126 | 156 | $ echo 're:.HGIGNORE' > .hgignore |
|
127 | 157 | $ echo 're:(?i)^[^a].*\.O$' >> .hgignore |
|
128 | 158 | $ hg status |
@@ -134,6 +164,10 Check that '^' after flag is properly de | |||
|
134 | 164 | $ hg debugignore |
|
135 | 165 | <includematcher includes='.*.HGIGNORE|(?i:^[^a].*\\.O$)'> |
|
136 | 166 | |
|
167 | #if rhg | |
|
168 | $ hg debugignorerhg | |
|
169 | .*.HGIGNORE|(?i:^[^a].*\.O$) | |
|
170 | #endif | |
|
137 | 171 | |
|
138 | 172 | further testing |
|
139 | 173 | --------------- |
@@ -317,6 +351,22 Test relative ignore path (issue4473): | |||
|
317 | 351 | ? a.o |
|
318 | 352 | ? dir/c.o |
|
319 | 353 | |
|
354 | $ echo "rootglob:dir/b.o" > .hgignore | |
|
355 | $ hg status | |
|
356 | A dir/b.o | |
|
357 | ? .hgignore | |
|
358 | ? a.c | |
|
359 | ? a.o | |
|
360 | ? dir/c.o | |
|
361 | ? syntax | |
|
362 | #if rhg | |
|
363 | $ hg debugignorerhg -a | |
|
364 | dir/b\.o(?:/|$) | |
|
365 | ||
|
366 | $ hg debugignorerhg | |
|
367 | ||
|
368 | #endif | |
|
369 | ||
|
320 | 370 | $ echo "relglob:*" > .hgignore |
|
321 | 371 | $ hg status |
|
322 | 372 | A dir/b.o |
@@ -328,6 +378,11 Test relative ignore path (issue4473): | |||
|
328 | 378 | $ hg debugignore |
|
329 | 379 | <includematcher includes='.*(?:/|$)'> |
|
330 | 380 | |
|
381 | #if rhg | |
|
382 | $ hg debugignorerhg | |
|
383 | .*(?:/|$) | |
|
384 | #endif | |
|
385 | ||
|
331 | 386 | $ hg debugignore b.o |
|
332 | 387 | b.o is ignored |
|
333 | 388 | (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: '*') (glob) |
General Comments 0
You need to be logged in to leave comments.
Login now