Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/dirstate_tree/status.rs @ 49550: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 | 8ee3889bab92 |
children | c52435820bbd 18282cf18aa2 |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/status.rs Wed Nov 02 15:24:39 2022 +0100 +++ b/rust/hg-core/src/dirstate_tree/status.rs Wed Nov 02 12:05:34 2022 +0100 @@ -10,6 +10,7 @@ use crate::matchers::get_ignore_function; use crate::matchers::Matcher; use crate::utils::files::get_bytes_from_os_string; +use crate::utils::files::get_bytes_from_path; use crate::utils::files::get_path_from_bytes; use crate::utils::hg_path::HgPath; use crate::BadMatch; @@ -66,7 +67,7 @@ let (ignore_fn, warnings) = get_ignore_function( ignore_files, &root_dir, - &mut |_pattern_bytes| {}, + &mut |_source, _pattern_bytes| {}, )?; (ignore_fn, warnings, None) } @@ -75,7 +76,24 @@ let (ignore_fn, warnings) = get_ignore_function( ignore_files, &root_dir, - &mut |pattern_bytes| hasher.update(pattern_bytes), + &mut |source, pattern_bytes| { + // If inside the repo, use the relative version to + // make it deterministic inside tests. + // The performance hit should be negligible. + let source = source + .strip_prefix(&root_dir) + .unwrap_or(source); + let source = get_bytes_from_path(source); + + let mut subhasher = Sha1::new(); + subhasher.update(pattern_bytes); + let patterns_hash = subhasher.finalize(); + + hasher.update(source); + hasher.update(b" "); + hasher.update(patterns_hash); + hasher.update(b"\n"); + }, )?; let new_hash = *hasher.finalize().as_ref(); let changed = new_hash != dmap.ignore_patterns_hash;