equal
deleted
inserted
replaced
8 use crate::dirstate::parsers::clear_ambiguous_mtime; |
8 use crate::dirstate::parsers::clear_ambiguous_mtime; |
9 use crate::dirstate::parsers::Timestamp; |
9 use crate::dirstate::parsers::Timestamp; |
10 use crate::errors::HgError; |
10 use crate::errors::HgError; |
11 use crate::revlog::node::NULL_NODE; |
11 use crate::revlog::node::NULL_NODE; |
12 use crate::{ |
12 use crate::{ |
13 dirstate::{parsers::PARENT_SIZE, EntryState, SIZE_FROM_OTHER_PARENT}, |
13 dirstate::{parsers::PARENT_SIZE, EntryState}, |
14 pack_dirstate, parse_dirstate, |
14 pack_dirstate, parse_dirstate, |
15 utils::{ |
15 utils::{ |
16 files::normalize_case, |
16 files::normalize_case, |
17 hg_path::{HgPath, HgPathBuf}, |
17 hg_path::{HgPath, HgPathBuf}, |
18 }, |
18 }, |
25 use std::iter::FromIterator; |
25 use std::iter::FromIterator; |
26 use std::ops::Deref; |
26 use std::ops::Deref; |
27 |
27 |
28 pub type FileFoldMap = FastHashMap<HgPathBuf, HgPathBuf>; |
28 pub type FileFoldMap = FastHashMap<HgPathBuf, HgPathBuf>; |
29 |
29 |
30 const MTIME_UNSET: i32 = -1; |
|
31 |
|
32 #[derive(Default)] |
30 #[derive(Default)] |
33 pub struct DirstateMap { |
31 pub struct DirstateMap { |
34 state_map: StateMap, |
32 state_map: StateMap, |
35 pub copy_map: CopyMap, |
33 pub copy_map: CopyMap, |
36 file_fold_map: Option<FileFoldMap>, |
34 file_fold_map: Option<FileFoldMap>, |
97 all_dirs.add_path(filename)?; |
95 all_dirs.add_path(filename)?; |
98 } |
96 } |
99 } |
97 } |
100 self.state_map.insert(filename.to_owned(), entry.to_owned()); |
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 self.get_non_normal_other_parent_entries() |
101 self.get_non_normal_other_parent_entries() |
104 .0 |
102 .0 |
105 .insert(filename.to_owned()); |
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 self.get_non_normal_other_parent_entries() |
107 self.get_non_normal_other_parent_entries() |
110 .1 |
108 .1 |
111 .insert(filename.to_owned()); |
109 .insert(filename.to_owned()); |
112 } |
110 } |
113 Ok(()) |
111 Ok(()) |
197 } |
195 } |
198 } |
196 } |
199 } |
197 } |
200 } |
198 } |
201 |
199 |
202 pub fn non_normal_entries_remove( |
200 pub fn non_normal_entries_remove(&mut self, key: impl AsRef<HgPath>) { |
203 &mut self, |
|
204 key: impl AsRef<HgPath>, |
|
205 ) -> bool { |
|
206 self.get_non_normal_other_parent_entries() |
201 self.get_non_normal_other_parent_entries() |
207 .0 |
202 .0 |
208 .remove(key.as_ref()) |
203 .remove(key.as_ref()); |
209 } |
204 } |
|
205 |
210 pub fn non_normal_entries_union( |
206 pub fn non_normal_entries_union( |
211 &mut self, |
207 &mut self, |
212 other: HashSet<HgPathBuf>, |
208 other: HashSet<HgPathBuf>, |
213 ) -> Vec<HgPathBuf> { |
209 ) -> Vec<HgPathBuf> { |
214 self.get_non_normal_other_parent_entries() |
210 self.get_non_normal_other_parent_entries() |
255 return; |
251 return; |
256 } |
252 } |
257 let mut non_normal = HashSet::new(); |
253 let mut non_normal = HashSet::new(); |
258 let mut other_parent = HashSet::new(); |
254 let mut other_parent = HashSet::new(); |
259 |
255 |
260 for ( |
256 for (filename, entry) in self.state_map.iter() { |
261 filename, |
257 if entry.is_non_normal() { |
262 DirstateEntry { |
|
263 state, size, mtime, .. |
|
264 }, |
|
265 ) in self.state_map.iter() |
|
266 { |
|
267 if *state != EntryState::Normal || *mtime == MTIME_UNSET { |
|
268 non_normal.insert(filename.to_owned()); |
258 non_normal.insert(filename.to_owned()); |
269 } |
259 } |
270 if *state == EntryState::Normal && *size == SIZE_FROM_OTHER_PARENT |
260 if entry.is_from_other_parent() { |
271 { |
|
272 other_parent.insert(filename.to_owned()); |
261 other_parent.insert(filename.to_owned()); |
273 } |
262 } |
274 } |
263 } |
275 self.non_normal_set = Some(non_normal); |
264 self.non_normal_set = Some(non_normal); |
276 self.other_parent_set = Some(other_parent); |
265 self.other_parent_set = Some(other_parent); |