Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/matchers.rs @ 47409:0ef8231e413f
dirstate-v2: Store a hash of ignore patterns (.hgignore)
Later, this help extend `read_dir` caching to directories that contain ignored
files (but no unknown files). Such cache must be invalidated when ignore patterns
change since a formerly-ignored file might become unknown.
This helps the default configuration of `hg status` where unknown files must
be listed, but ignored files are not.
Differential Revision: https://phab.mercurial-scm.org/D10836
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 02 Jun 2021 11:25:18 +0200 |
parents | f6bb181c75f8 |
children | 6d69e83e6b6e |
line wrap: on
line diff
--- a/rust/hg-core/src/matchers.rs Mon Jun 07 17:29:32 2021 +0530 +++ b/rust/hg-core/src/matchers.rs Wed Jun 02 11:25:18 2021 +0200 @@ -564,8 +564,9 @@ /// function that checks whether a given file (in the general sense) should be /// ignored. pub fn get_ignore_function<'a>( - all_pattern_files: Vec<PathBuf>, + mut all_pattern_files: Vec<PathBuf>, root_dir: &Path, + inspect_pattern_bytes: &mut impl FnMut(&[u8]), ) -> PatternResult<( Box<dyn for<'r> Fn(&'r HgPath) -> bool + Sync + 'a>, Vec<PatternFileWarning>, @@ -573,9 +574,20 @@ let mut all_patterns = vec![]; let mut all_warnings = vec![]; + // Sort to make the ordering of calls to `inspect_pattern_bytes` + // deterministic even if the ordering of `all_pattern_files` is not (such + // as when a iteration order of a Python dict or Rust HashMap is involved). + // Sort by "string" representation instead of the default by component + // (with a Rust-specific definition of a component) + all_pattern_files + .sort_unstable_by(|a, b| a.as_os_str().cmp(b.as_os_str())); + for pattern_file in &all_pattern_files { - let (patterns, warnings) = - get_patterns_from_file(pattern_file, root_dir)?; + let (patterns, warnings) = get_patterns_from_file( + pattern_file, + root_dir, + inspect_pattern_bytes, + )?; all_patterns.extend(patterns.to_owned()); all_warnings.extend(warnings);