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