equal
deleted
inserted
replaced
322 lines: &[u8], |
322 lines: &[u8], |
323 file_path: P, |
323 file_path: P, |
324 warn: bool, |
324 warn: bool, |
325 ) -> Result<(Vec<IgnorePattern>, Vec<PatternFileWarning>), PatternError> { |
325 ) -> Result<(Vec<IgnorePattern>, Vec<PatternFileWarning>), PatternError> { |
326 let comment_regex = Regex::new(r"((?:^|[^\\])(?:\\\\)*)#.*").unwrap(); |
326 let comment_regex = Regex::new(r"((?:^|[^\\])(?:\\\\)*)#.*").unwrap(); |
|
327 |
|
328 #[allow(clippy::trivial_regex)] |
327 let comment_escape_regex = Regex::new(r"\\#").unwrap(); |
329 let comment_escape_regex = Regex::new(r"\\#").unwrap(); |
328 let mut inputs: Vec<IgnorePattern> = vec![]; |
330 let mut inputs: Vec<IgnorePattern> = vec![]; |
329 let mut warnings: Vec<PatternFileWarning> = vec![]; |
331 let mut warnings: Vec<PatternFileWarning> = vec![]; |
330 |
332 |
331 let mut current_syntax = b"relre:".as_ref(); |
333 let mut current_syntax = b"relre:".as_ref(); |
456 let (patterns, mut warnings) = read_pattern_file(&pattern_file, true)?; |
458 let (patterns, mut warnings) = read_pattern_file(&pattern_file, true)?; |
457 let patterns = patterns |
459 let patterns = patterns |
458 .into_iter() |
460 .into_iter() |
459 .flat_map(|entry| -> PatternResult<_> { |
461 .flat_map(|entry| -> PatternResult<_> { |
460 let IgnorePattern { |
462 let IgnorePattern { |
461 syntax, |
463 syntax, pattern, .. |
462 pattern, |
|
463 source: _, |
|
464 } = &entry; |
464 } = &entry; |
465 Ok(match syntax { |
465 Ok(match syntax { |
466 PatternSyntax::Include => { |
466 PatternSyntax::Include => { |
467 let inner_include = |
467 let inner_include = |
468 root_dir.as_ref().join(get_path_from_bytes(&pattern)); |
468 root_dir.as_ref().join(get_path_from_bytes(&pattern)); |
502 ) -> Result<SubInclude, HgPathError> { |
502 ) -> Result<SubInclude, HgPathError> { |
503 let normalized_source = |
503 let normalized_source = |
504 normalize_path_bytes(&get_bytes_from_path(source)); |
504 normalize_path_bytes(&get_bytes_from_path(source)); |
505 |
505 |
506 let source_root = get_path_from_bytes(&normalized_source); |
506 let source_root = get_path_from_bytes(&normalized_source); |
507 let source_root = source_root.parent().unwrap_or(source_root.deref()); |
507 let source_root = |
|
508 source_root.parent().unwrap_or_else(|| source_root.deref()); |
508 |
509 |
509 let path = source_root.join(get_path_from_bytes(pattern)); |
510 let path = source_root.join(get_path_from_bytes(pattern)); |
510 let new_root = path.parent().unwrap_or(path.deref()); |
511 let new_root = path.parent().unwrap_or_else(|| path.deref()); |
511 |
512 |
512 let prefix = canonical_path(&root_dir, &root_dir, new_root)?; |
513 let prefix = canonical_path(&root_dir, &root_dir, new_root)?; |
513 |
514 |
514 Ok(Self { |
515 Ok(Self { |
515 prefix: path_to_hg_path_buf(prefix).and_then(|mut p| { |
516 prefix: path_to_hg_path_buf(prefix).and_then(|mut p| { |