equal
deleted
inserted
replaced
393 /// assert_eq!(matcher.matches(HgPath::new(b"this should work")), true); |
393 /// assert_eq!(matcher.matches(HgPath::new(b"this should work")), true); |
394 /// assert_eq!(matcher.matches(HgPath::new(b"this also")), true); |
394 /// assert_eq!(matcher.matches(HgPath::new(b"this also")), true); |
395 /// assert_eq!(matcher.matches(HgPath::new(b"but not this")), false); |
395 /// assert_eq!(matcher.matches(HgPath::new(b"but not this")), false); |
396 /// /// |
396 /// /// |
397 /// let ignore_patterns = |
397 /// let ignore_patterns = |
398 /// vec![IgnorePattern::new(PatternSyntax::RootFiles, b"dir/subdir", Path::new(""))]; |
398 /// vec![IgnorePattern::new(PatternSyntax::RootFilesIn, b"dir/subdir", Path::new(""))]; |
399 /// let matcher = IncludeMatcher::new(ignore_patterns).unwrap(); |
399 /// let matcher = IncludeMatcher::new(ignore_patterns).unwrap(); |
400 /// /// |
400 /// /// |
401 /// assert!(!matcher.matches(HgPath::new(b"file"))); |
401 /// assert!(!matcher.matches(HgPath::new(b"file"))); |
402 /// assert!(!matcher.matches(HgPath::new(b"dir/file"))); |
402 /// assert!(!matcher.matches(HgPath::new(b"dir/file"))); |
403 /// assert!(matcher.matches(HgPath::new(b"dir/subdir/file"))); |
403 /// assert!(matcher.matches(HgPath::new(b"dir/subdir/file"))); |
864 } else { |
864 } else { |
865 pattern |
865 pattern |
866 }); |
866 }); |
867 roots.push(pat.to_owned()); |
867 roots.push(pat.to_owned()); |
868 } |
868 } |
869 PatternSyntax::RootFiles => { |
869 PatternSyntax::RootFilesIn => { |
870 let pat = if pattern == b"." { |
870 let pat = if pattern == b"." { |
871 &[] as &[u8] |
871 &[] as &[u8] |
872 } else { |
872 } else { |
873 pattern |
873 pattern |
874 }; |
874 }; |
961 if !ignore_patterns.is_empty() { |
961 if !ignore_patterns.is_empty() { |
962 // Either do dumb matching if all patterns are rootfiles, or match |
962 // Either do dumb matching if all patterns are rootfiles, or match |
963 // with a regex. |
963 // with a regex. |
964 if ignore_patterns |
964 if ignore_patterns |
965 .iter() |
965 .iter() |
966 .all(|k| k.syntax == PatternSyntax::RootFiles) |
966 .all(|k| k.syntax == PatternSyntax::RootFilesIn) |
967 { |
967 { |
968 let dirs: HashSet<_> = ignore_patterns |
968 let dirs: HashSet<_> = ignore_patterns |
969 .iter() |
969 .iter() |
970 .map(|k| k.pattern.to_owned()) |
970 .map(|k| k.pattern.to_owned()) |
971 .collect(); |
971 .collect(); |
1322 VisitChildrenSet::Empty |
1322 VisitChildrenSet::Empty |
1323 ); |
1323 ); |
1324 |
1324 |
1325 // VisitdirRootfilesin |
1325 // VisitdirRootfilesin |
1326 let m = PatternMatcher::new(vec![IgnorePattern::new( |
1326 let m = PatternMatcher::new(vec![IgnorePattern::new( |
1327 PatternSyntax::RootFiles, |
1327 PatternSyntax::RootFilesIn, |
1328 b"dir/subdir", |
1328 b"dir/subdir", |
1329 Path::new(""), |
1329 Path::new(""), |
1330 )]) |
1330 )]) |
1331 .unwrap(); |
1331 .unwrap(); |
1332 assert_eq!( |
1332 assert_eq!( |
1351 VisitChildrenSet::Empty |
1351 VisitChildrenSet::Empty |
1352 ); |
1352 ); |
1353 |
1353 |
1354 // VisitchildrensetRootfilesin |
1354 // VisitchildrensetRootfilesin |
1355 let m = PatternMatcher::new(vec![IgnorePattern::new( |
1355 let m = PatternMatcher::new(vec![IgnorePattern::new( |
1356 PatternSyntax::RootFiles, |
1356 PatternSyntax::RootFilesIn, |
1357 b"dir/subdir", |
1357 b"dir/subdir", |
1358 Path::new(""), |
1358 Path::new(""), |
1359 )]) |
1359 )]) |
1360 .unwrap(); |
1360 .unwrap(); |
1361 assert_eq!( |
1361 assert_eq!( |
1535 VisitChildrenSet::Empty |
1535 VisitChildrenSet::Empty |
1536 ); |
1536 ); |
1537 |
1537 |
1538 // VisitchildrensetRootfilesin |
1538 // VisitchildrensetRootfilesin |
1539 let matcher = IncludeMatcher::new(vec![IgnorePattern::new( |
1539 let matcher = IncludeMatcher::new(vec![IgnorePattern::new( |
1540 PatternSyntax::RootFiles, |
1540 PatternSyntax::RootFilesIn, |
1541 b"dir/subdir", |
1541 b"dir/subdir", |
1542 Path::new(""), |
1542 Path::new(""), |
1543 )]) |
1543 )]) |
1544 .unwrap(); |
1544 .unwrap(); |
1545 |
1545 |
1670 b"dir/subdir", |
1670 b"dir/subdir", |
1671 Path::new(""), |
1671 Path::new(""), |
1672 )]) |
1672 )]) |
1673 .unwrap(); |
1673 .unwrap(); |
1674 let m2 = IncludeMatcher::new(vec![IgnorePattern::new( |
1674 let m2 = IncludeMatcher::new(vec![IgnorePattern::new( |
1675 PatternSyntax::RootFiles, |
1675 PatternSyntax::RootFilesIn, |
1676 b"dir", |
1676 b"dir", |
1677 Path::new(""), |
1677 Path::new(""), |
1678 )]) |
1678 )]) |
1679 .unwrap(); |
1679 .unwrap(); |
1680 let matcher = UnionMatcher::new(vec![Box::new(m1), Box::new(m2)]); |
1680 let matcher = UnionMatcher::new(vec![Box::new(m1), Box::new(m2)]); |
1831 )]) |
1831 )]) |
1832 .unwrap(), |
1832 .unwrap(), |
1833 ); |
1833 ); |
1834 let m2 = Box::new( |
1834 let m2 = Box::new( |
1835 IncludeMatcher::new(vec![IgnorePattern::new( |
1835 IncludeMatcher::new(vec![IgnorePattern::new( |
1836 PatternSyntax::RootFiles, |
1836 PatternSyntax::RootFilesIn, |
1837 b"dir", |
1837 b"dir", |
1838 Path::new(""), |
1838 Path::new(""), |
1839 )]) |
1839 )]) |
1840 .unwrap(), |
1840 .unwrap(), |
1841 ); |
1841 ); |
2082 )]) |
2082 )]) |
2083 .unwrap(), |
2083 .unwrap(), |
2084 ); |
2084 ); |
2085 let m2 = Box::new( |
2085 let m2 = Box::new( |
2086 IncludeMatcher::new(vec![IgnorePattern::new( |
2086 IncludeMatcher::new(vec![IgnorePattern::new( |
2087 PatternSyntax::RootFiles, |
2087 PatternSyntax::RootFilesIn, |
2088 b"dir", |
2088 b"dir", |
2089 Path::new("/repo"), |
2089 Path::new("/repo"), |
2090 )]) |
2090 )]) |
2091 .unwrap(), |
2091 .unwrap(), |
2092 ); |
2092 ); |
2340 // No file in a/b/c |
2340 // No file in a/b/c |
2341 HgPathBuf::from_bytes(b"a/b/c/d/file.txt"), |
2341 HgPathBuf::from_bytes(b"a/b/c/d/file.txt"), |
2342 ]; |
2342 ]; |
2343 let file_abcdfile = FileMatcher::new(files).unwrap(); |
2343 let file_abcdfile = FileMatcher::new(files).unwrap(); |
2344 let _rootfilesin_dir = PatternMatcher::new(vec![IgnorePattern::new( |
2344 let _rootfilesin_dir = PatternMatcher::new(vec![IgnorePattern::new( |
2345 PatternSyntax::RootFiles, |
2345 PatternSyntax::RootFilesIn, |
2346 b"dir", |
2346 b"dir", |
2347 Path::new(""), |
2347 Path::new(""), |
2348 )]) |
2348 )]) |
2349 .unwrap(); |
2349 .unwrap(); |
2350 |
2350 |