comparison rust/hg-core/src/filepatterns.rs @ 49558:363923bd51cd stable

dirstate-v2: hash the source of the ignore patterns as well Fixes the test introduced in the last changeset. This caused the hash to change, which means that the check in the test had to be adapted. Since this hash is only done as a caching mechanism, invalidation does not pose any backwards compatibility issues.
author Rapha?l Gom?s <rgomes@octobus.net>
date Wed, 02 Nov 2022 12:05:34 +0100
parents 7c93e38a0bbd
children 086b0c4f8663
comparison
equal deleted inserted replaced
49557:ca19335e86e5 49558:363923bd51cd
410 } 410 }
411 411
412 pub fn read_pattern_file( 412 pub fn read_pattern_file(
413 file_path: &Path, 413 file_path: &Path,
414 warn: bool, 414 warn: bool,
415 inspect_pattern_bytes: &mut impl FnMut(&[u8]), 415 inspect_pattern_bytes: &mut impl FnMut(&Path, &[u8]),
416 ) -> Result<(Vec<IgnorePattern>, Vec<PatternFileWarning>), PatternError> { 416 ) -> Result<(Vec<IgnorePattern>, Vec<PatternFileWarning>), PatternError> {
417 match std::fs::read(file_path) { 417 match std::fs::read(file_path) {
418 Ok(contents) => { 418 Ok(contents) => {
419 inspect_pattern_bytes(&contents); 419 inspect_pattern_bytes(file_path, &contents);
420 parse_pattern_file_contents(&contents, file_path, None, warn) 420 parse_pattern_file_contents(&contents, file_path, None, warn)
421 } 421 }
422 Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(( 422 Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok((
423 vec![], 423 vec![],
424 vec![PatternFileWarning::NoSuchFile(file_path.to_owned())], 424 vec![PatternFileWarning::NoSuchFile(file_path.to_owned())],
453 /// The former are expanded in place, while `PatternSyntax::ExpandedSubInclude` 453 /// The former are expanded in place, while `PatternSyntax::ExpandedSubInclude`
454 /// is used for the latter to form a tree of patterns. 454 /// is used for the latter to form a tree of patterns.
455 pub fn get_patterns_from_file( 455 pub fn get_patterns_from_file(
456 pattern_file: &Path, 456 pattern_file: &Path,
457 root_dir: &Path, 457 root_dir: &Path,
458 inspect_pattern_bytes: &mut impl FnMut(&[u8]), 458 inspect_pattern_bytes: &mut impl FnMut(&Path, &[u8]),
459 ) -> PatternResult<(Vec<IgnorePattern>, Vec<PatternFileWarning>)> { 459 ) -> PatternResult<(Vec<IgnorePattern>, Vec<PatternFileWarning>)> {
460 let (patterns, mut warnings) = 460 let (patterns, mut warnings) =
461 read_pattern_file(pattern_file, true, inspect_pattern_bytes)?; 461 read_pattern_file(pattern_file, true, inspect_pattern_bytes)?;
462 let patterns = patterns 462 let patterns = patterns
463 .into_iter() 463 .into_iter()