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