##// END OF EJS Templates
rhg: refactor to use IgnoreFnType alias more widely...
Arseniy Alekseyev -
r49177:2009e3c6 default
parent child Browse files
Show More
@@ -22,6 +22,7 b' use crate::{'
22 PatternSyntax,
22 PatternSyntax,
23 };
23 };
24
24
25 use crate::dirstate::status::IgnoreFnType;
25 use crate::filepatterns::normalize_path_bytes;
26 use crate::filepatterns::normalize_path_bytes;
26 use std::borrow::ToOwned;
27 use std::borrow::ToOwned;
27 use std::collections::HashSet;
28 use std::collections::HashSet;
@@ -246,7 +247,7 b" impl<'a> Matcher for FileMatcher<'a> {"
246 /// ```
247 /// ```
247 pub struct IncludeMatcher<'a> {
248 pub struct IncludeMatcher<'a> {
248 patterns: Vec<u8>,
249 patterns: Vec<u8>,
249 match_fn: Box<dyn for<'r> Fn(&'r HgPath) -> bool + 'a + Sync>,
250 match_fn: IgnoreFnType<'a>,
250 /// Whether all the patterns match a prefix (i.e. recursively)
251 /// Whether all the patterns match a prefix (i.e. recursively)
251 prefix: bool,
252 prefix: bool,
252 roots: HashSet<HgPathBuf>,
253 roots: HashSet<HgPathBuf>,
@@ -341,9 +342,9 b' fn re_matcher('
341
342
342 /// Returns the regex pattern and a function that matches an `HgPath` against
343 /// Returns the regex pattern and a function that matches an `HgPath` against
343 /// said regex formed by the given ignore patterns.
344 /// said regex formed by the given ignore patterns.
344 fn build_regex_match(
345 fn build_regex_match<'a, 'b>(
345 ignore_patterns: &[IgnorePattern],
346 ignore_patterns: &'a [IgnorePattern],
346 ) -> PatternResult<(Vec<u8>, Box<dyn Fn(&HgPath) -> bool + Sync>)> {
347 ) -> PatternResult<(Vec<u8>, IgnoreFnType<'b>)> {
347 let mut regexps = vec![];
348 let mut regexps = vec![];
348 let mut exact_set = HashSet::new();
349 let mut exact_set = HashSet::new();
349
350
@@ -365,10 +366,10 b' fn build_regex_match('
365 let func = move |filename: &HgPath| {
366 let func = move |filename: &HgPath| {
366 exact_set.contains(filename) || matcher(filename)
367 exact_set.contains(filename) || matcher(filename)
367 };
368 };
368 Box::new(func) as Box<dyn Fn(&HgPath) -> bool + Sync>
369 Box::new(func) as IgnoreFnType
369 } else {
370 } else {
370 let func = move |filename: &HgPath| exact_set.contains(filename);
371 let func = move |filename: &HgPath| exact_set.contains(filename);
371 Box::new(func) as Box<dyn Fn(&HgPath) -> bool + Sync>
372 Box::new(func) as IgnoreFnType
372 };
373 };
373
374
374 Ok((full_regex, func))
375 Ok((full_regex, func))
@@ -476,8 +477,8 b' fn roots_dirs_and_parents('
476 /// should be matched.
477 /// should be matched.
477 fn build_match<'a, 'b>(
478 fn build_match<'a, 'b>(
478 ignore_patterns: Vec<IgnorePattern>,
479 ignore_patterns: Vec<IgnorePattern>,
479 ) -> PatternResult<(Vec<u8>, Box<dyn Fn(&HgPath) -> bool + 'b + Sync>)> {
480 ) -> PatternResult<(Vec<u8>, IgnoreFnType<'b>)> {
480 let mut match_funcs: Vec<Box<dyn Fn(&HgPath) -> bool + Sync>> = vec![];
481 let mut match_funcs: Vec<IgnoreFnType<'b>> = vec![];
481 // For debugging and printing
482 // For debugging and printing
482 let mut patterns = vec![];
483 let mut patterns = vec![];
483
484
@@ -564,10 +565,7 b" pub fn get_ignore_function<'a>("
564 mut all_pattern_files: Vec<PathBuf>,
565 mut all_pattern_files: Vec<PathBuf>,
565 root_dir: &Path,
566 root_dir: &Path,
566 inspect_pattern_bytes: &mut impl FnMut(&[u8]),
567 inspect_pattern_bytes: &mut impl FnMut(&[u8]),
567 ) -> PatternResult<(
568 ) -> PatternResult<(IgnoreFnType<'a>, Vec<PatternFileWarning>)> {
568 Box<dyn for<'r> Fn(&'r HgPath) -> bool + Sync + 'a>,
569 Vec<PatternFileWarning>,
570 )> {
571 let mut all_patterns = vec![];
569 let mut all_patterns = vec![];
572 let mut all_warnings = vec![];
570 let mut all_warnings = vec![];
573
571
General Comments 0
You need to be logged in to leave comments. Login now