55 RelGlob, |
55 RelGlob, |
56 /// A regexp that needn't match the start of a name |
56 /// A regexp that needn't match the start of a name |
57 RelRegexp, |
57 RelRegexp, |
58 /// A path relative to repository root, which is matched non-recursively |
58 /// A path relative to repository root, which is matched non-recursively |
59 /// (will not match subdirectories) |
59 /// (will not match subdirectories) |
60 RootFiles, |
60 RootFilesIn, |
61 /// A file of patterns to read and include |
61 /// A file of patterns to read and include |
62 Include, |
62 Include, |
63 /// A file of patterns to match against files under the same directory |
63 /// A file of patterns to match against files under the same directory |
64 SubInclude, |
64 SubInclude, |
65 /// SubInclude with the result of parsing the included file |
65 /// SubInclude with the result of parsing the included file |
156 match kind { |
156 match kind { |
157 b"re:" => Ok(PatternSyntax::Regexp), |
157 b"re:" => Ok(PatternSyntax::Regexp), |
158 b"path:" => Ok(PatternSyntax::Path), |
158 b"path:" => Ok(PatternSyntax::Path), |
159 b"filepath:" => Ok(PatternSyntax::FilePath), |
159 b"filepath:" => Ok(PatternSyntax::FilePath), |
160 b"relpath:" => Ok(PatternSyntax::RelPath), |
160 b"relpath:" => Ok(PatternSyntax::RelPath), |
161 b"rootfilesin:" => Ok(PatternSyntax::RootFiles), |
161 b"rootfilesin:" => Ok(PatternSyntax::RootFilesIn), |
162 b"relglob:" => Ok(PatternSyntax::RelGlob), |
162 b"relglob:" => Ok(PatternSyntax::RelGlob), |
163 b"relre:" => Ok(PatternSyntax::RelRegexp), |
163 b"relre:" => Ok(PatternSyntax::RelRegexp), |
164 b"glob:" => Ok(PatternSyntax::Glob), |
164 b"glob:" => Ok(PatternSyntax::Glob), |
165 b"rootglob:" => Ok(PatternSyntax::RootGlob), |
165 b"rootglob:" => Ok(PatternSyntax::RootGlob), |
166 b"include:" => Ok(PatternSyntax::Include), |
166 b"include:" => Ok(PatternSyntax::Include), |
225 if pattern == b"." { |
225 if pattern == b"." { |
226 return vec![]; |
226 return vec![]; |
227 } |
227 } |
228 [escape_pattern(pattern).as_slice(), b"(?:/|$)"].concat() |
228 [escape_pattern(pattern).as_slice(), b"(?:/|$)"].concat() |
229 } |
229 } |
230 PatternSyntax::RootFiles => { |
230 PatternSyntax::RootFilesIn => { |
231 let mut res = if pattern == b"." { |
231 let mut res = if pattern == b"." { |
232 vec![] |
232 vec![] |
233 } else { |
233 } else { |
234 // Pattern is a directory name. |
234 // Pattern is a directory name. |
235 [escape_pattern(pattern).as_slice(), b"/"].concat() |
235 [escape_pattern(pattern).as_slice(), b"/"].concat() |
314 let pattern = match syntax { |
314 let pattern = match syntax { |
315 PatternSyntax::RootGlob |
315 PatternSyntax::RootGlob |
316 | PatternSyntax::Path |
316 | PatternSyntax::Path |
317 | PatternSyntax::RelGlob |
317 | PatternSyntax::RelGlob |
318 | PatternSyntax::RelPath |
318 | PatternSyntax::RelPath |
319 | PatternSyntax::RootFiles => normalize_path_bytes(pattern), |
319 | PatternSyntax::RootFilesIn => normalize_path_bytes(pattern), |
320 PatternSyntax::Include | PatternSyntax::SubInclude => { |
320 PatternSyntax::Include | PatternSyntax::SubInclude => { |
321 return Err(PatternError::NonRegexPattern(entry.clone())) |
321 return Err(PatternError::NonRegexPattern(entry.clone())) |
322 } |
322 } |
323 _ => pattern.to_owned(), |
323 _ => pattern.to_owned(), |
324 }; |
324 }; |
340 m.insert(b"re:".as_ref(), PatternSyntax::Regexp); |
340 m.insert(b"re:".as_ref(), PatternSyntax::Regexp); |
341 m.insert(b"regexp:".as_ref(), PatternSyntax::Regexp); |
341 m.insert(b"regexp:".as_ref(), PatternSyntax::Regexp); |
342 m.insert(b"path:".as_ref(), PatternSyntax::Path); |
342 m.insert(b"path:".as_ref(), PatternSyntax::Path); |
343 m.insert(b"filepath:".as_ref(), PatternSyntax::FilePath); |
343 m.insert(b"filepath:".as_ref(), PatternSyntax::FilePath); |
344 m.insert(b"relpath:".as_ref(), PatternSyntax::RelPath); |
344 m.insert(b"relpath:".as_ref(), PatternSyntax::RelPath); |
345 m.insert(b"rootfilesin:".as_ref(), PatternSyntax::RootFiles); |
345 m.insert(b"rootfilesin:".as_ref(), PatternSyntax::RootFilesIn); |
346 m.insert(b"relglob:".as_ref(), PatternSyntax::RelGlob); |
346 m.insert(b"relglob:".as_ref(), PatternSyntax::RelGlob); |
347 m.insert(b"relre:".as_ref(), PatternSyntax::RelRegexp); |
347 m.insert(b"relre:".as_ref(), PatternSyntax::RelRegexp); |
348 m.insert(b"glob:".as_ref(), PatternSyntax::Glob); |
348 m.insert(b"glob:".as_ref(), PatternSyntax::Glob); |
349 m.insert(b"rootglob:".as_ref(), PatternSyntax::RootGlob); |
349 m.insert(b"rootglob:".as_ref(), PatternSyntax::RootGlob); |
350 m.insert(b"include:".as_ref(), PatternSyntax::Include); |
350 m.insert(b"include:".as_ref(), PatternSyntax::Include); |
383 PatternSyntax::RootGlob |
383 PatternSyntax::RootGlob |
384 | PatternSyntax::Path |
384 | PatternSyntax::Path |
385 | PatternSyntax::Glob |
385 | PatternSyntax::Glob |
386 | PatternSyntax::RelGlob |
386 | PatternSyntax::RelGlob |
387 | PatternSyntax::RelPath |
387 | PatternSyntax::RelPath |
388 | PatternSyntax::RootFiles |
388 | PatternSyntax::RootFilesIn |
389 if normalize => |
389 if normalize => |
390 { |
390 { |
391 normalize_path_bytes(pattern_bytes) |
391 normalize_path_bytes(pattern_bytes) |
392 } |
392 } |
393 _ => pattern_bytes.to_vec(), |
393 _ => pattern_bytes.to_vec(), |