Show More
@@ -34,6 +34,16 b' pub struct DirstateEntry {' | |||
|
34 | 34 | pub size: i32, |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | impl DirstateEntry { | |
|
38 | pub fn is_non_normal(&self) -> bool { | |
|
39 | self.state != EntryState::Normal || self.mtime == MTIME_UNSET | |
|
40 | } | |
|
41 | ||
|
42 | pub fn is_from_other_parent(&self) -> bool { | |
|
43 | self.state == EntryState::Normal && self.size == SIZE_FROM_OTHER_PARENT | |
|
44 | } | |
|
45 | } | |
|
46 | ||
|
37 | 47 | #[derive(BytesCast)] |
|
38 | 48 | #[repr(C)] |
|
39 | 49 | struct RawEntry { |
@@ -44,6 +54,8 b' struct RawEntry {' | |||
|
44 | 54 | length: unaligned::I32Be, |
|
45 | 55 | } |
|
46 | 56 | |
|
57 | const MTIME_UNSET: i32 = -1; | |
|
58 | ||
|
47 | 59 | /// A `DirstateEntry` with a size of `-2` means that it was merged from the |
|
48 | 60 | /// other parent. This allows revert to pick the right status back during a |
|
49 | 61 | /// merge. |
@@ -10,7 +10,7 b' use crate::dirstate::parsers::Timestamp;' | |||
|
10 | 10 | use crate::errors::HgError; |
|
11 | 11 | use crate::revlog::node::NULL_NODE; |
|
12 | 12 | use crate::{ |
|
13 |
dirstate::{parsers::PARENT_SIZE, EntryState |
|
|
13 | dirstate::{parsers::PARENT_SIZE, EntryState}, | |
|
14 | 14 | pack_dirstate, parse_dirstate, |
|
15 | 15 | utils::{ |
|
16 | 16 | files::normalize_case, |
@@ -27,8 +27,6 b' use std::ops::Deref;' | |||
|
27 | 27 | |
|
28 | 28 | pub type FileFoldMap = FastHashMap<HgPathBuf, HgPathBuf>; |
|
29 | 29 | |
|
30 | const MTIME_UNSET: i32 = -1; | |
|
31 | ||
|
32 | 30 | #[derive(Default)] |
|
33 | 31 | pub struct DirstateMap { |
|
34 | 32 | state_map: StateMap, |
@@ -99,13 +97,13 b' impl DirstateMap {' | |||
|
99 | 97 | } |
|
100 | 98 | self.state_map.insert(filename.to_owned(), entry.to_owned()); |
|
101 | 99 | |
|
102 | if entry.state != EntryState::Normal || entry.mtime == MTIME_UNSET { | |
|
100 | if entry.is_non_normal() { | |
|
103 | 101 | self.get_non_normal_other_parent_entries() |
|
104 | 102 | .0 |
|
105 | 103 | .insert(filename.to_owned()); |
|
106 | 104 | } |
|
107 | 105 | |
|
108 | if entry.size == SIZE_FROM_OTHER_PARENT { | |
|
106 | if entry.is_from_other_parent() { | |
|
109 | 107 | self.get_non_normal_other_parent_entries() |
|
110 | 108 | .1 |
|
111 | 109 | .insert(filename.to_owned()); |
@@ -199,14 +197,12 b' impl DirstateMap {' | |||
|
199 | 197 | } |
|
200 | 198 | } |
|
201 | 199 | |
|
202 | pub fn non_normal_entries_remove( | |
|
203 | &mut self, | |
|
204 | key: impl AsRef<HgPath>, | |
|
205 | ) -> bool { | |
|
200 | pub fn non_normal_entries_remove(&mut self, key: impl AsRef<HgPath>) { | |
|
206 | 201 | self.get_non_normal_other_parent_entries() |
|
207 | 202 | .0 |
|
208 | .remove(key.as_ref()) | |
|
203 | .remove(key.as_ref()); | |
|
209 | 204 | } |
|
205 | ||
|
210 | 206 | pub fn non_normal_entries_union( |
|
211 | 207 | &mut self, |
|
212 | 208 | other: HashSet<HgPathBuf>, |
@@ -257,18 +253,11 b' impl DirstateMap {' | |||
|
257 | 253 | let mut non_normal = HashSet::new(); |
|
258 | 254 | let mut other_parent = HashSet::new(); |
|
259 | 255 | |
|
260 | for ( | |
|
261 | filename, | |
|
262 | DirstateEntry { | |
|
263 | state, size, mtime, .. | |
|
264 | }, | |
|
265 | ) in self.state_map.iter() | |
|
266 | { | |
|
267 | if *state != EntryState::Normal || *mtime == MTIME_UNSET { | |
|
256 | for (filename, entry) in self.state_map.iter() { | |
|
257 | if entry.is_non_normal() { | |
|
268 | 258 | non_normal.insert(filename.to_owned()); |
|
269 | 259 | } |
|
270 | if *state == EntryState::Normal && *size == SIZE_FROM_OTHER_PARENT | |
|
271 | { | |
|
260 | if entry.is_from_other_parent() { | |
|
272 | 261 | other_parent.insert(filename.to_owned()); |
|
273 | 262 | } |
|
274 | 263 | } |
@@ -397,40 +397,61 b' impl super::dispatch::DirstateMapMethods' | |||
|
397 | 397 | } |
|
398 | 398 | } |
|
399 | 399 | |
|
400 |
fn non_normal_entries_contains(&mut self, |
|
|
401 |
|
|
|
400 | fn non_normal_entries_contains(&mut self, key: &HgPath) -> bool { | |
|
401 | self.get_node(key) | |
|
402 | .and_then(|node| node.entry.as_ref()) | |
|
403 | .map_or(false, DirstateEntry::is_non_normal) | |
|
402 | 404 | } |
|
403 | 405 | |
|
404 |
fn non_normal_entries_remove(&mut self, _key: &HgPath) |
|
|
405 | todo!() | |
|
406 | fn non_normal_entries_remove(&mut self, _key: &HgPath) { | |
|
407 | // Do nothing, this `DirstateMap` does not have a separate "non normal | |
|
408 | // entries" set that need to be kept up to date | |
|
406 | 409 | } |
|
407 | 410 | |
|
408 | 411 | fn non_normal_or_other_parent_paths( |
|
409 | 412 | &mut self, |
|
410 | 413 | ) -> Box<dyn Iterator<Item = &HgPathBuf> + '_> { |
|
411 | todo!() | |
|
414 | Box::new(self.iter_nodes().filter_map(|(path, node)| { | |
|
415 | node.entry | |
|
416 | .as_ref() | |
|
417 | .filter(|entry| { | |
|
418 | entry.is_non_normal() || entry.is_from_other_parent() | |
|
419 | }) | |
|
420 | .map(|_| path.full_path()) | |
|
421 | })) | |
|
412 | 422 | } |
|
413 | 423 | |
|
414 | 424 | fn set_non_normal_other_parent_entries(&mut self, _force: bool) { |
|
415 | todo!() | |
|
425 | // Do nothing, this `DirstateMap` does not have a separate "non normal | |
|
426 | // entries" and "from other parent" sets that need to be recomputed | |
|
416 | 427 | } |
|
417 | 428 | |
|
418 | 429 | fn iter_non_normal_paths( |
|
419 | 430 | &mut self, |
|
420 | 431 | ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> { |
|
421 | todo!() | |
|
432 | self.iter_non_normal_paths_panic() | |
|
422 | 433 | } |
|
423 | 434 | |
|
424 | 435 | fn iter_non_normal_paths_panic( |
|
425 | 436 | &self, |
|
426 | 437 | ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> { |
|
427 | todo!() | |
|
438 | Box::new(self.iter_nodes().filter_map(|(path, node)| { | |
|
439 | node.entry | |
|
440 | .as_ref() | |
|
441 | .filter(|entry| entry.is_non_normal()) | |
|
442 | .map(|_| path.full_path()) | |
|
443 | })) | |
|
428 | 444 | } |
|
429 | 445 | |
|
430 | 446 | fn iter_other_parent_paths( |
|
431 | 447 | &mut self, |
|
432 | 448 | ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> { |
|
433 | todo!() | |
|
449 | Box::new(self.iter_nodes().filter_map(|(path, node)| { | |
|
450 | node.entry | |
|
451 | .as_ref() | |
|
452 | .filter(|entry| entry.is_from_other_parent()) | |
|
453 | .map(|_| path.full_path()) | |
|
454 | })) | |
|
434 | 455 | } |
|
435 | 456 | |
|
436 | 457 | fn has_tracked_dir( |
@@ -45,7 +45,7 b' pub trait DirstateMapMethods {' | |||
|
45 | 45 | |
|
46 | 46 | fn non_normal_entries_contains(&mut self, key: &HgPath) -> bool; |
|
47 | 47 | |
|
48 |
fn non_normal_entries_remove(&mut self, key: &HgPath) |
|
|
48 | fn non_normal_entries_remove(&mut self, key: &HgPath); | |
|
49 | 49 | |
|
50 | 50 | fn non_normal_or_other_parent_paths( |
|
51 | 51 | &mut self, |
@@ -179,7 +179,7 b' impl DirstateMapMethods for DirstateMap ' | |||
|
179 | 179 | non_normal.contains(key) |
|
180 | 180 | } |
|
181 | 181 | |
|
182 |
fn non_normal_entries_remove(&mut self, key: &HgPath) |
|
|
182 | fn non_normal_entries_remove(&mut self, key: &HgPath) { | |
|
183 | 183 | self.non_normal_entries_remove(key) |
|
184 | 184 | } |
|
185 | 185 |
General Comments 0
You need to be logged in to leave comments.
Login now