comparison rust/hg-core/src/dirstate_tree/dispatch.rs @ 47692:e5fb14a07866

dirstate-map: move most of `dirstate.update_file` logic in the dsmap A new `reset_state` method is introduced to deal with most of that logic. This move things one layer lower, but the ultimate goal is to deal with most of this at the DirstateItem level. This reveal various imperfection with the data passed to update_file by `mergestate.recordupdates`, however this is orthogonal to this patch and should be dealt with at a higher level. Differential Revision: https://phab.mercurial-scm.org/D11134
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 19 Jul 2021 07:23:55 +0200
parents 284a20269a97
children 357307feaf61
comparison
equal deleted inserted replaced
47691:33beeb32f73a 47692:e5fb14a07866
35 /// various information about the state of those files. 35 /// various information about the state of those files.
36 pub trait DirstateMapMethods { 36 pub trait DirstateMapMethods {
37 /// Remove information about all files in this map 37 /// Remove information about all files in this map
38 fn clear(&mut self); 38 fn clear(&mut self);
39 39
40 fn set_v1(&mut self, filename: &HgPath, entry: DirstateEntry);
41
40 /// Add or change the information associated to a given file. 42 /// Add or change the information associated to a given file.
41 /// 43 ///
42 /// `old_state` is the state in the entry that `get` would have returned 44 /// `old_state` is the state in the entry that `get` would have returned
43 /// before this call, or `EntryState::Unknown` if there was no such entry. 45 /// before this call, or `EntryState::Unknown` if there was no such entry.
44 /// 46 ///
93 ) -> Result<bool, DirstateV2ParseError>; 95 ) -> Result<bool, DirstateV2ParseError>;
94 96
95 /// Mark the given path as "normal" file. This is only relevant in the flat 97 /// Mark the given path as "normal" file. This is only relevant in the flat
96 /// dirstate map where there is a separate `HashSet` that needs to be kept 98 /// dirstate map where there is a separate `HashSet` that needs to be kept
97 /// up to date. 99 /// up to date.
98 fn non_normal_entries_remove(&mut self, key: &HgPath); 100 /// Returns whether the key was present in the set.
101 fn non_normal_entries_remove(&mut self, key: &HgPath) -> bool;
102
103 /// Mark the given path as "non-normal" file.
104 /// This is only relevant in the flat dirstate map where there is a
105 /// separate `HashSet` that needs to be kept up to date.
106 fn non_normal_entries_add(&mut self, key: &HgPath);
99 107
100 /// Return an iterator of paths whose respective entry are either 108 /// Return an iterator of paths whose respective entry are either
101 /// "non-normal" (see `non_normal_entries_contains`) or "from other 109 /// "non-normal" (see `non_normal_entries_contains`) or "from other
102 /// parent". 110 /// parent".
103 /// 111 ///
303 impl DirstateMapMethods for DirstateMap { 311 impl DirstateMapMethods for DirstateMap {
304 fn clear(&mut self) { 312 fn clear(&mut self) {
305 self.clear() 313 self.clear()
306 } 314 }
307 315
316 /// Used to set a value directory.
317 ///
318 /// XXX Is temporary during a refactor of V1 dirstate and will disappear
319 /// shortly.
320 fn set_v1(&mut self, filename: &HgPath, entry: DirstateEntry) {
321 self.set_v1_inner(&filename, entry)
322 }
323
308 fn add_file( 324 fn add_file(
309 &mut self, 325 &mut self,
310 filename: &HgPath, 326 filename: &HgPath,
311 entry: DirstateEntry, 327 entry: DirstateEntry,
312 added: bool, 328 added: bool,
344 let (non_normal, _other_parent) = 360 let (non_normal, _other_parent) =
345 self.get_non_normal_other_parent_entries(); 361 self.get_non_normal_other_parent_entries();
346 Ok(non_normal.contains(key)) 362 Ok(non_normal.contains(key))
347 } 363 }
348 364
349 fn non_normal_entries_remove(&mut self, key: &HgPath) { 365 fn non_normal_entries_remove(&mut self, key: &HgPath) -> bool {
350 self.non_normal_entries_remove(key) 366 self.non_normal_entries_remove(key)
367 }
368
369 fn non_normal_entries_add(&mut self, key: &HgPath) {
370 self.non_normal_entries_add(key)
351 } 371 }
352 372
353 fn non_normal_or_other_parent_paths( 373 fn non_normal_or_other_parent_paths(
354 &mut self, 374 &mut self,
355 ) -> Box<dyn Iterator<Item = Result<&HgPath, DirstateV2ParseError>> + '_> 375 ) -> Box<dyn Iterator<Item = Result<&HgPath, DirstateV2ParseError>> + '_>