Show More
@@ -176,9 +176,7 b' fn _build_single_regex(entry: &IgnorePat' | |||
|
176 | 176 | return vec![]; |
|
177 | 177 | } |
|
178 | 178 | match syntax { |
|
179 | // The `regex` crate adds `.*` to the start and end of expressions | |
|
180 | // if there are no anchors, so add them. | |
|
181 | PatternSyntax::Regexp => [b"^", &pattern[..], b"$"].concat(), | |
|
179 | PatternSyntax::Regexp => pattern.to_owned(), | |
|
182 | 180 | PatternSyntax::RelRegexp => { |
|
183 | 181 | // The `regex` crate accepts `**` while `re2` and Python's `re` |
|
184 | 182 | // do not. Checking for `*` correctly triggers the same error all |
@@ -196,15 +194,14 b' fn _build_single_regex(entry: &IgnorePat' | |||
|
196 | 194 | } |
|
197 | 195 | PatternSyntax::RootFiles => { |
|
198 | 196 | let mut res = if pattern == b"." { |
|
199 |
vec![ |
|
|
197 | vec![] | |
|
200 | 198 | } else { |
|
201 | 199 | // Pattern is a directory name. |
|
202 |
[ |
|
|
200 | [escape_pattern(pattern).as_slice(), b"/"].concat() | |
|
203 | 201 | }; |
|
204 | 202 | |
|
205 | 203 | // Anything after the pattern must be a non-directory. |
|
206 | 204 | res.extend(b"[^/]+$"); |
|
207 | res.push(b'$'); | |
|
208 | 205 | res |
|
209 | 206 | } |
|
210 | 207 | PatternSyntax::RelGlob => { |
@@ -216,7 +213,7 b' fn _build_single_regex(entry: &IgnorePat' | |||
|
216 | 213 | } |
|
217 | 214 | } |
|
218 | 215 | PatternSyntax::Glob | PatternSyntax::RootGlob => { |
|
219 |
[ |
|
|
216 | [glob_to_re(pattern).as_slice(), GLOB_SUFFIX].concat() | |
|
220 | 217 | } |
|
221 | 218 | PatternSyntax::Include | PatternSyntax::SubInclude => unreachable!(), |
|
222 | 219 | } |
@@ -654,7 +651,7 b' mod tests {' | |||
|
654 | 651 | Path::new("") |
|
655 | 652 | )) |
|
656 | 653 | .unwrap(), |
|
657 |
Some(br" |
|
|
654 | Some(br"[^/]*\.o(?:/|$)".to_vec()), | |
|
658 | 655 | ); |
|
659 | 656 | } |
|
660 | 657 | } |
@@ -347,7 +347,9 b' fn re_matcher(' | |||
|
347 | 347 | ) -> PatternResult<impl Fn(&HgPath) -> bool + Sync> { |
|
348 | 348 | use std::io::Write; |
|
349 | 349 | |
|
350 | let mut escaped_bytes = vec![]; | |
|
350 | // The `regex` crate adds `.*` to the start and end of expressions if there | |
|
351 | // are no anchors, so add the start anchor. | |
|
352 | let mut escaped_bytes = vec![b'^', b'(', b'?', b':']; | |
|
351 | 353 | for byte in pattern { |
|
352 | 354 | if *byte > 127 { |
|
353 | 355 | write!(escaped_bytes, "\\x{:x}", *byte).unwrap(); |
@@ -355,6 +357,7 b' fn re_matcher(' | |||
|
355 | 357 | escaped_bytes.push(*byte); |
|
356 | 358 | } |
|
357 | 359 | } |
|
360 | escaped_bytes.push(b')'); | |
|
358 | 361 | |
|
359 | 362 | // Avoid the cost of UTF8 checking |
|
360 | 363 | // |
General Comments 0
You need to be logged in to leave comments.
Login now