comparison rust/hg-core/src/dirstate_tree/status.rs @ 49546:ecf9788cd9c4 stable

rust-status: fix typos and add docstrings to dircache related fields
author Rapha?l Gom?s <rgomes@octobus.net>
date Wed, 19 Oct 2022 15:11:05 +0200
parents eb02decdf0ab
children 8ee3889bab92
comparison
equal deleted inserted replaced
49545:557f7e243ac9 49546:ecf9788cd9c4
119 options, 119 options,
120 matcher, 120 matcher,
121 ignore_fn, 121 ignore_fn,
122 outcome: Mutex::new(outcome), 122 outcome: Mutex::new(outcome),
123 ignore_patterns_have_changed: patterns_changed, 123 ignore_patterns_have_changed: patterns_changed,
124 new_cachable_directories: Default::default(), 124 new_cacheable_directories: Default::default(),
125 outated_cached_directories: Default::default(), 125 outdated_cached_directories: Default::default(),
126 filesystem_time_at_status_start, 126 filesystem_time_at_status_start,
127 }; 127 };
128 let is_at_repo_root = true; 128 let is_at_repo_root = true;
129 let hg_path = &BorrowedPath::OnDisk(HgPath::new("")); 129 let hg_path = &BorrowedPath::OnDisk(HgPath::new(""));
130 let has_ignored_ancestor = HasIgnoredAncestor::create(None, hg_path); 130 let has_ignored_ancestor = HasIgnoredAncestor::create(None, hg_path);
141 root_dir_metadata, 141 root_dir_metadata,
142 root_cached_mtime, 142 root_cached_mtime,
143 is_at_repo_root, 143 is_at_repo_root,
144 )?; 144 )?;
145 let mut outcome = common.outcome.into_inner().unwrap(); 145 let mut outcome = common.outcome.into_inner().unwrap();
146 let new_cachable = common.new_cachable_directories.into_inner().unwrap(); 146 let new_cacheable = common.new_cacheable_directories.into_inner().unwrap();
147 let outdated = common.outated_cached_directories.into_inner().unwrap(); 147 let outdated = common.outdated_cached_directories.into_inner().unwrap();
148 148
149 outcome.dirty = common.ignore_patterns_have_changed == Some(true) 149 outcome.dirty = common.ignore_patterns_have_changed == Some(true)
150 || !outdated.is_empty() 150 || !outdated.is_empty()
151 || (!new_cachable.is_empty() 151 || (!new_cacheable.is_empty()
152 && dmap.dirstate_version == DirstateVersion::V2); 152 && dmap.dirstate_version == DirstateVersion::V2);
153 153
154 // Remove outdated mtimes before adding new mtimes, in case a given 154 // Remove outdated mtimes before adding new mtimes, in case a given
155 // directory is both 155 // directory is both
156 for path in &outdated { 156 for path in &outdated {
157 dmap.clear_cached_mtime(path)?; 157 dmap.clear_cached_mtime(path)?;
158 } 158 }
159 for (path, mtime) in &new_cachable { 159 for (path, mtime) in &new_cacheable {
160 dmap.set_cached_mtime(path, *mtime)?; 160 dmap.set_cached_mtime(path, *mtime)?;
161 } 161 }
162 162
163 Ok((outcome, warnings)) 163 Ok((outcome, warnings))
164 } 164 }
169 dmap: &'tree DirstateMap<'on_disk>, 169 dmap: &'tree DirstateMap<'on_disk>,
170 options: StatusOptions, 170 options: StatusOptions,
171 matcher: &'a (dyn Matcher + Sync), 171 matcher: &'a (dyn Matcher + Sync),
172 ignore_fn: IgnoreFnType<'a>, 172 ignore_fn: IgnoreFnType<'a>,
173 outcome: Mutex<DirstateStatus<'on_disk>>, 173 outcome: Mutex<DirstateStatus<'on_disk>>,
174 new_cachable_directories: 174 /// New timestamps of directories to be used for caching their readdirs
175 new_cacheable_directories:
175 Mutex<Vec<(Cow<'on_disk, HgPath>, TruncatedTimestamp)>>, 176 Mutex<Vec<(Cow<'on_disk, HgPath>, TruncatedTimestamp)>>,
176 outated_cached_directories: Mutex<Vec<Cow<'on_disk, HgPath>>>, 177 /// Used to invalidate the readdir cache of directories
178 outdated_cached_directories: Mutex<Vec<Cow<'on_disk, HgPath>>>,
177 179
178 /// Whether ignore files like `.hgignore` have changed since the previous 180 /// Whether ignore files like `.hgignore` have changed since the previous
179 /// time a `status()` call wrote their hash to the dirstate. `None` means 181 /// time a `status()` call wrote their hash to the dirstate. `None` means
180 /// we don’t know as this run doesn’t list either ignored or uknown files 182 /// we don’t know as this run doesn’t list either ignored or uknown files
181 /// and therefore isn’t reading `.hgignore`. 183 /// and therefore isn’t reading `.hgignore`.
303 dirstate_node: &NodeRef<'tree, 'on_disk>, 305 dirstate_node: &NodeRef<'tree, 'on_disk>,
304 ) -> Result<(), DirstateV2ParseError> { 306 ) -> Result<(), DirstateV2ParseError> {
305 if self.ignore_patterns_have_changed == Some(true) 307 if self.ignore_patterns_have_changed == Some(true)
306 && dirstate_node.cached_directory_mtime()?.is_some() 308 && dirstate_node.cached_directory_mtime()?.is_some()
307 { 309 {
308 self.outated_cached_directories.lock().unwrap().push( 310 self.outdated_cached_directories.lock().unwrap().push(
309 dirstate_node 311 dirstate_node
310 .full_path_borrowed(self.dmap.on_disk)? 312 .full_path_borrowed(self.dmap.on_disk)?
311 .detach_from_tree(), 313 .detach_from_tree(),
312 ) 314 )
313 } 315 }
627 }; 629 };
628 if !is_up_to_date { 630 if !is_up_to_date {
629 let hg_path = dirstate_node 631 let hg_path = dirstate_node
630 .full_path_borrowed(self.dmap.on_disk)? 632 .full_path_borrowed(self.dmap.on_disk)?
631 .detach_from_tree(); 633 .detach_from_tree();
632 self.new_cachable_directories 634 self.new_cacheable_directories
633 .lock() 635 .lock()
634 .unwrap() 636 .unwrap()
635 .push((hg_path, directory_mtime)) 637 .push((hg_path, directory_mtime))
636 } 638 }
637 Ok(()) 639 Ok(())