Mercurial > public > mercurial-scm > hg-stable
comparison rust/hg-core/src/dirstate_tree/dispatch.rs @ 47108:e061a1df32a8
dirstate-tree: Abstract "non-normal" and "other parent" sets
Instead of exposing `HashSet`s directly, have slightly higher-level
methods for the operations that Python bindings need on them.
Differential Revision: https://phab.mercurial-scm.org/D10363
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Thu, 08 Apr 2021 14:58:44 +0200 |
parents | 787ff5d21bcd |
children | 5d62243c7732 |
comparison
equal
deleted
inserted
replaced
47107:787ff5d21bcd | 47108:e061a1df32a8 |
---|---|
1 use std::collections::HashSet; | |
2 use std::path::PathBuf; | 1 use std::path::PathBuf; |
3 use std::time::Duration; | 2 use std::time::Duration; |
4 | 3 |
5 use crate::matchers::Matcher; | 4 use crate::matchers::Matcher; |
6 use crate::utils::hg_path::{HgPath, HgPathBuf}; | 5 use crate::utils::hg_path::{HgPath, HgPathBuf}; |
42 old_state: EntryState, | 41 old_state: EntryState, |
43 ) -> Result<bool, DirstateMapError>; | 42 ) -> Result<bool, DirstateMapError>; |
44 | 43 |
45 fn clear_ambiguous_times(&mut self, filenames: Vec<HgPathBuf>, now: i32); | 44 fn clear_ambiguous_times(&mut self, filenames: Vec<HgPathBuf>, now: i32); |
46 | 45 |
46 fn non_normal_entries_contains(&mut self, key: &HgPath) -> bool; | |
47 | |
47 fn non_normal_entries_remove(&mut self, key: &HgPath) -> bool; | 48 fn non_normal_entries_remove(&mut self, key: &HgPath) -> bool; |
48 | 49 |
49 fn non_normal_entries_union( | 50 fn non_normal_or_other_parent_paths( |
50 &mut self, | 51 &mut self, |
51 other: HashSet<HgPathBuf>, | 52 ) -> Box<dyn Iterator<Item = &HgPathBuf> + '_>; |
52 ) -> Vec<HgPathBuf>; | |
53 | 53 |
54 fn set_non_normal_other_parent_entries(&mut self, force: bool); | 54 fn set_non_normal_other_parent_entries(&mut self, force: bool); |
55 | 55 |
56 fn get_non_normal_other_parent_entries_panic( | 56 fn iter_non_normal_paths( |
57 &mut self, | |
58 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_>; | |
59 | |
60 fn iter_non_normal_paths_panic( | |
57 &self, | 61 &self, |
58 ) -> (&HashSet<HgPathBuf>, &HashSet<HgPathBuf>); | 62 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_>; |
59 | 63 |
60 fn get_non_normal_other_parent_entries( | 64 fn iter_other_parent_paths( |
61 &mut self, | 65 &mut self, |
62 ) -> (&mut HashSet<HgPathBuf>, &mut HashSet<HgPathBuf>); | 66 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_>; |
63 | 67 |
64 fn has_tracked_dir( | 68 fn has_tracked_dir( |
65 &mut self, | 69 &mut self, |
66 directory: &HgPath, | 70 directory: &HgPath, |
67 ) -> Result<bool, DirstateMapError>; | 71 ) -> Result<bool, DirstateMapError>; |
167 | 171 |
168 fn clear_ambiguous_times(&mut self, filenames: Vec<HgPathBuf>, now: i32) { | 172 fn clear_ambiguous_times(&mut self, filenames: Vec<HgPathBuf>, now: i32) { |
169 self.clear_ambiguous_times(filenames, now) | 173 self.clear_ambiguous_times(filenames, now) |
170 } | 174 } |
171 | 175 |
176 fn non_normal_entries_contains(&mut self, key: &HgPath) -> bool { | |
177 let (non_normal, _other_parent) = | |
178 self.get_non_normal_other_parent_entries(); | |
179 non_normal.contains(key) | |
180 } | |
181 | |
172 fn non_normal_entries_remove(&mut self, key: &HgPath) -> bool { | 182 fn non_normal_entries_remove(&mut self, key: &HgPath) -> bool { |
173 self.non_normal_entries_remove(key) | 183 self.non_normal_entries_remove(key) |
174 } | 184 } |
175 | 185 |
176 fn non_normal_entries_union( | 186 fn non_normal_or_other_parent_paths( |
177 &mut self, | 187 &mut self, |
178 other: HashSet<HgPathBuf>, | 188 ) -> Box<dyn Iterator<Item = &HgPathBuf> + '_> { |
179 ) -> Vec<HgPathBuf> { | 189 let (non_normal, other_parent) = |
180 self.non_normal_entries_union(other) | 190 self.get_non_normal_other_parent_entries(); |
191 Box::new(non_normal.union(other_parent)) | |
181 } | 192 } |
182 | 193 |
183 fn set_non_normal_other_parent_entries(&mut self, force: bool) { | 194 fn set_non_normal_other_parent_entries(&mut self, force: bool) { |
184 self.set_non_normal_other_parent_entries(force) | 195 self.set_non_normal_other_parent_entries(force) |
185 } | 196 } |
186 | 197 |
187 fn get_non_normal_other_parent_entries_panic( | 198 fn iter_non_normal_paths( |
199 &mut self, | |
200 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> { | |
201 let (non_normal, _other_parent) = | |
202 self.get_non_normal_other_parent_entries(); | |
203 Box::new(non_normal.iter()) | |
204 } | |
205 | |
206 fn iter_non_normal_paths_panic( | |
188 &self, | 207 &self, |
189 ) -> (&HashSet<HgPathBuf>, &HashSet<HgPathBuf>) { | 208 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> { |
190 self.get_non_normal_other_parent_entries_panic() | 209 let (non_normal, _other_parent) = |
191 } | 210 self.get_non_normal_other_parent_entries_panic(); |
192 | 211 Box::new(non_normal.iter()) |
193 fn get_non_normal_other_parent_entries( | 212 } |
194 &mut self, | 213 |
195 ) -> (&mut HashSet<HgPathBuf>, &mut HashSet<HgPathBuf>) { | 214 fn iter_other_parent_paths( |
196 self.get_non_normal_other_parent_entries() | 215 &mut self, |
216 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> { | |
217 let (_non_normal, other_parent) = | |
218 self.get_non_normal_other_parent_entries(); | |
219 Box::new(other_parent.iter()) | |
197 } | 220 } |
198 | 221 |
199 fn has_tracked_dir( | 222 fn has_tracked_dir( |
200 &mut self, | 223 &mut self, |
201 directory: &HgPath, | 224 directory: &HgPath, |