Show More
@@ -12,12 +12,9 b' use crate::revlog::node::NULL_NODE;' | |||
|
12 | 12 | use crate::{ |
|
13 | 13 | dirstate::{parsers::PARENT_SIZE, EntryState}, |
|
14 | 14 | pack_dirstate, parse_dirstate, |
|
15 | utils::{ | |
|
16 | files::normalize_case, | |
|
17 | hg_path::{HgPath, HgPathBuf}, | |
|
18 | }, | |
|
15 | utils::hg_path::{HgPath, HgPathBuf}, | |
|
19 | 16 | CopyMap, DirsMultiset, DirstateEntry, DirstateError, DirstateMapError, |
|
20 |
DirstateParents, |
|
|
17 | DirstateParents, StateMap, | |
|
21 | 18 | }; |
|
22 | 19 | use micro_timer::timed; |
|
23 | 20 | use std::collections::HashSet; |
@@ -25,13 +22,10 b' use std::convert::TryInto;' | |||
|
25 | 22 | use std::iter::FromIterator; |
|
26 | 23 | use std::ops::Deref; |
|
27 | 24 | |
|
28 | pub type FileFoldMap = FastHashMap<HgPathBuf, HgPathBuf>; | |
|
29 | ||
|
30 | 25 | #[derive(Default)] |
|
31 | 26 | pub struct DirstateMap { |
|
32 | 27 | state_map: StateMap, |
|
33 | 28 | pub copy_map: CopyMap, |
|
34 | file_fold_map: Option<FileFoldMap>, | |
|
35 | 29 | pub dirs: Option<DirsMultiset>, |
|
36 | 30 | pub all_dirs: Option<DirsMultiset>, |
|
37 | 31 | non_normal_set: Option<HashSet<HgPathBuf>>, |
@@ -68,7 +62,6 b' impl DirstateMap {' | |||
|
68 | 62 | pub fn clear(&mut self) { |
|
69 | 63 | self.state_map = StateMap::default(); |
|
70 | 64 | self.copy_map.clear(); |
|
71 | self.file_fold_map = None; | |
|
72 | 65 | self.non_normal_set = None; |
|
73 | 66 | self.other_parent_set = None; |
|
74 | 67 | self.set_parents(&DirstateParents { |
@@ -134,9 +127,6 b' impl DirstateMap {' | |||
|
134 | 127 | } |
|
135 | 128 | } |
|
136 | 129 | |
|
137 | if let Some(ref mut file_fold_map) = self.file_fold_map { | |
|
138 | file_fold_map.remove(&normalize_case(filename)); | |
|
139 | } | |
|
140 | 130 | self.state_map.insert( |
|
141 | 131 | filename.to_owned(), |
|
142 | 132 | DirstateEntry { |
@@ -171,9 +161,6 b' impl DirstateMap {' | |||
|
171 | 161 | all_dirs.delete_path(filename)?; |
|
172 | 162 | } |
|
173 | 163 | } |
|
174 | if let Some(ref mut file_fold_map) = self.file_fold_map { | |
|
175 | file_fold_map.remove(&normalize_case(filename)); | |
|
176 | } | |
|
177 | 164 | self.get_non_normal_other_parent_entries() |
|
178 | 165 | .0 |
|
179 | 166 | .remove(filename); |
@@ -381,21 +368,6 b' impl DirstateMap {' | |||
|
381 | 368 | self.set_non_normal_other_parent_entries(true); |
|
382 | 369 | Ok(packed) |
|
383 | 370 | } |
|
384 | pub fn build_file_fold_map(&mut self) -> &FileFoldMap { | |
|
385 | if let Some(ref file_fold_map) = self.file_fold_map { | |
|
386 | return file_fold_map; | |
|
387 | } | |
|
388 | let mut new_file_fold_map = FileFoldMap::default(); | |
|
389 | ||
|
390 | for (filename, DirstateEntry { state, .. }) in self.state_map.iter() { | |
|
391 | if *state != EntryState::Removed { | |
|
392 | new_file_fold_map | |
|
393 | .insert(normalize_case(&filename), filename.to_owned()); | |
|
394 | } | |
|
395 | } | |
|
396 | self.file_fold_map = Some(new_file_fold_map); | |
|
397 | self.file_fold_map.as_ref().unwrap() | |
|
398 | } | |
|
399 | 371 | } |
|
400 | 372 | |
|
401 | 373 | #[cfg(test)] |
@@ -19,7 +19,6 b' use crate::DirstateMapError;' | |||
|
19 | 19 | use crate::DirstateParents; |
|
20 | 20 | use crate::DirstateStatus; |
|
21 | 21 | use crate::EntryState; |
|
22 | use crate::FastHashMap; | |
|
23 | 22 | use crate::HgPathCow; |
|
24 | 23 | use crate::PatternFileWarning; |
|
25 | 24 | use crate::StateMapIter; |
@@ -565,10 +564,6 b' impl super::dispatch::DirstateMapMethods' | |||
|
565 | 564 | Ok(packed) |
|
566 | 565 | } |
|
567 | 566 | |
|
568 | fn build_file_fold_map(&mut self) -> &FastHashMap<HgPathBuf, HgPathBuf> { | |
|
569 | todo!() | |
|
570 | } | |
|
571 | ||
|
572 | 567 | fn set_all_dirs(&mut self) -> Result<(), DirstateMapError> { |
|
573 | 568 | // Do nothing, this `DirstateMap` does not a separate `all_dirs` that |
|
574 | 569 | // needs to be recomputed |
@@ -11,7 +11,6 b' use crate::DirstateMapError;' | |||
|
11 | 11 | use crate::DirstateParents; |
|
12 | 12 | use crate::DirstateStatus; |
|
13 | 13 | use crate::EntryState; |
|
14 | use crate::FastHashMap; | |
|
15 | 14 | use crate::HgPathCow; |
|
16 | 15 | use crate::PatternFileWarning; |
|
17 | 16 | use crate::StateMapIter; |
@@ -93,8 +92,6 b' pub trait DirstateMapMethods {' | |||
|
93 | 92 | now: Timestamp, |
|
94 | 93 | ) -> Result<Vec<u8>, DirstateError>; |
|
95 | 94 | |
|
96 | fn build_file_fold_map(&mut self) -> &FastHashMap<HgPathBuf, HgPathBuf>; | |
|
97 | ||
|
98 | 95 | fn set_all_dirs(&mut self) -> Result<(), DirstateMapError>; |
|
99 | 96 | |
|
100 | 97 | fn set_dirs(&mut self) -> Result<(), DirstateMapError>; |
@@ -259,10 +256,6 b' impl DirstateMapMethods for DirstateMap ' | |||
|
259 | 256 | self.pack(parents, now) |
|
260 | 257 | } |
|
261 | 258 | |
|
262 | fn build_file_fold_map(&mut self) -> &FastHashMap<HgPathBuf, HgPathBuf> { | |
|
263 | self.build_file_fold_map() | |
|
264 | } | |
|
265 | ||
|
266 | 259 | fn set_all_dirs(&mut self) -> Result<(), DirstateMapError> { |
|
267 | 260 | self.set_all_dirs() |
|
268 | 261 | } |
@@ -30,6 +30,7 b' use hg::{' | |||
|
30 | 30 | dirstate_tree::dispatch::DirstateMapMethods, |
|
31 | 31 | errors::HgError, |
|
32 | 32 | revlog::Node, |
|
33 | utils::files::normalize_case, | |
|
33 | 34 | utils::hg_path::{HgPath, HgPathBuf}, |
|
34 | 35 | DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap, |
|
35 | 36 | DirstateMapError, DirstateParents, EntryState, StateMapIter, |
@@ -329,15 +330,17 b' py_class!(pub class DirstateMap |py| {' | |||
|
329 | 330 | |
|
330 | 331 | def filefoldmapasdict(&self) -> PyResult<PyDict> { |
|
331 | 332 | let dict = PyDict::new(py); |
|
332 | for (key, value) in | |
|
333 | self.inner(py).borrow_mut().build_file_fold_map().iter() | |
|
334 | { | |
|
333 | for (path, entry) in self.inner(py).borrow_mut().iter() { | |
|
334 | if entry.state != EntryState::Removed { | |
|
335 | let key = normalize_case(path); | |
|
336 | let value = path; | |
|
335 | 337 | dict.set_item( |
|
336 | 338 | py, |
|
337 | 339 | PyBytes::new(py, key.as_bytes()).into_object(), |
|
338 | 340 | PyBytes::new(py, value.as_bytes()).into_object(), |
|
339 | 341 | )?; |
|
340 | 342 | } |
|
343 | } | |
|
341 | 344 | Ok(dict) |
|
342 | 345 | } |
|
343 | 346 |
General Comments 0
You need to be logged in to leave comments.
Login now