Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/dirstate_tree/status.rs @ 49337:6cd249556e20 stable
rust-status: don't trigger dirstate v1 rewrite when only v2 data is changed
The assumption that we need to rewrite (or append to) the dirstate if the
ignore pattern hash has changed or if any cached directory mtimes have changed
is only valid when using dirstate-v2. In dirstate-v1, neither of these things
are written to disk.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Wed, 08 Jun 2022 19:15:58 +0200 |
parents | dd6b67d5c256 |
children | 79b2c98ab7b4 |
comparison
equal
deleted
inserted
replaced
49320:3d3d7fc6035a | 49337:6cd249556e20 |
---|---|
2 use crate::dirstate::status::IgnoreFnType; | 2 use crate::dirstate::status::IgnoreFnType; |
3 use crate::dirstate::status::StatusPath; | 3 use crate::dirstate::status::StatusPath; |
4 use crate::dirstate_tree::dirstate_map::BorrowedPath; | 4 use crate::dirstate_tree::dirstate_map::BorrowedPath; |
5 use crate::dirstate_tree::dirstate_map::ChildNodesRef; | 5 use crate::dirstate_tree::dirstate_map::ChildNodesRef; |
6 use crate::dirstate_tree::dirstate_map::DirstateMap; | 6 use crate::dirstate_tree::dirstate_map::DirstateMap; |
7 use crate::dirstate_tree::dirstate_map::DirstateVersion; | |
7 use crate::dirstate_tree::dirstate_map::NodeData; | 8 use crate::dirstate_tree::dirstate_map::NodeData; |
8 use crate::dirstate_tree::dirstate_map::NodeRef; | 9 use crate::dirstate_tree::dirstate_map::NodeRef; |
9 use crate::dirstate_tree::on_disk::DirstateV2ParseError; | 10 use crate::dirstate_tree::on_disk::DirstateV2ParseError; |
10 use crate::matchers::get_ignore_function; | 11 use crate::matchers::get_ignore_function; |
11 use crate::matchers::Matcher; | 12 use crate::matchers::Matcher; |
59 .build_global() | 60 .build_global() |
60 .ok(); | 61 .ok(); |
61 | 62 |
62 let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) = | 63 let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) = |
63 if options.list_ignored || options.list_unknown { | 64 if options.list_ignored || options.list_unknown { |
64 let mut hasher = Sha1::new(); | 65 let (ignore_fn, warnings, changed) = match dmap.dirstate_version { |
65 let (ignore_fn, warnings) = get_ignore_function( | 66 DirstateVersion::V1 => { |
66 ignore_files, | 67 let (ignore_fn, warnings) = get_ignore_function( |
67 &root_dir, | 68 ignore_files, |
68 &mut |pattern_bytes| hasher.update(pattern_bytes), | 69 &root_dir, |
69 )?; | 70 &mut |_pattern_bytes| {}, |
70 let new_hash = *hasher.finalize().as_ref(); | 71 )?; |
71 let changed = new_hash != dmap.ignore_patterns_hash; | 72 (ignore_fn, warnings, None) |
72 dmap.ignore_patterns_hash = new_hash; | 73 } |
73 (ignore_fn, warnings, Some(changed)) | 74 DirstateVersion::V2 => { |
75 let mut hasher = Sha1::new(); | |
76 let (ignore_fn, warnings) = get_ignore_function( | |
77 ignore_files, | |
78 &root_dir, | |
79 &mut |pattern_bytes| hasher.update(pattern_bytes), | |
80 )?; | |
81 let new_hash = *hasher.finalize().as_ref(); | |
82 let changed = new_hash != dmap.ignore_patterns_hash; | |
83 dmap.ignore_patterns_hash = new_hash; | |
84 (ignore_fn, warnings, Some(changed)) | |
85 } | |
86 }; | |
87 (ignore_fn, warnings, changed) | |
74 } else { | 88 } else { |
75 (Box::new(|&_| true), vec![], None) | 89 (Box::new(|&_| true), vec![], None) |
76 }; | 90 }; |
77 | 91 |
78 let filesystem_time_at_status_start = | 92 let filesystem_time_at_status_start = |
133 let new_cachable = common.new_cachable_directories.into_inner().unwrap(); | 147 let new_cachable = common.new_cachable_directories.into_inner().unwrap(); |
134 let outdated = common.outated_cached_directories.into_inner().unwrap(); | 148 let outdated = common.outated_cached_directories.into_inner().unwrap(); |
135 | 149 |
136 outcome.dirty = common.ignore_patterns_have_changed == Some(true) | 150 outcome.dirty = common.ignore_patterns_have_changed == Some(true) |
137 || !outdated.is_empty() | 151 || !outdated.is_empty() |
138 || !new_cachable.is_empty(); | 152 || (!new_cachable.is_empty() |
153 && dmap.dirstate_version == DirstateVersion::V2); | |
139 | 154 |
140 // Remove outdated mtimes before adding new mtimes, in case a given | 155 // Remove outdated mtimes before adding new mtimes, in case a given |
141 // directory is both | 156 // directory is both |
142 for path in &outdated { | 157 for path in &outdated { |
143 let node = dmap.get_or_insert(path)?; | 158 let node = dmap.get_or_insert(path)?; |