##// END OF EJS Templates
rust: Remove EntryState::Unknown...
Simon Sapin -
r48838:1b2ee68e default
parent child Browse files
Show More
@@ -111,17 +111,13 b' impl DirstateMap {'
111 111 let mode = entry.mode();
112 112 let entry = DirstateEntry::from_v1_data(state, mode, size, mtime);
113 113
114 let old_state = match self.get(filename) {
115 Some(e) => e.state(),
116 None => EntryState::Unknown,
117 };
118 if old_state == EntryState::Unknown || old_state == EntryState::Removed
119 {
114 let old_state = self.get(filename).map(|e| e.state());
115 if old_state.is_none() || old_state == Some(EntryState::Removed) {
120 116 if let Some(ref mut dirs) = self.dirs {
121 117 dirs.add_path(filename)?;
122 118 }
123 119 }
124 if old_state == EntryState::Unknown {
120 if old_state.is_none() {
125 121 if let Some(ref mut all_dirs) = self.all_dirs {
126 122 all_dirs.add_path(filename)?;
127 123 }
@@ -153,10 +149,7 b' impl DirstateMap {'
153 149 in_merge: bool,
154 150 ) -> Result<(), DirstateError> {
155 151 let old_entry_opt = self.get(filename);
156 let old_state = match old_entry_opt {
157 Some(e) => e.state(),
158 None => EntryState::Unknown,
159 };
152 let old_state = old_entry_opt.map(|e| e.state());
160 153 let mut size = 0;
161 154 if in_merge {
162 155 // XXX we should not be able to have 'm' state and 'FROM_P2' if not
@@ -178,13 +171,12 b' impl DirstateMap {'
178 171 }
179 172 }
180 173 }
181 if old_state != EntryState::Unknown && old_state != EntryState::Removed
182 {
174 if old_state.is_some() && old_state != Some(EntryState::Removed) {
183 175 if let Some(ref mut dirs) = self.dirs {
184 176 dirs.delete_path(filename)?;
185 177 }
186 178 }
187 if old_state == EntryState::Unknown {
179 if old_state.is_none() {
188 180 if let Some(ref mut all_dirs) = self.all_dirs {
189 181 all_dirs.add_path(filename)?;
190 182 }
@@ -207,14 +199,11 b' impl DirstateMap {'
207 199 &mut self,
208 200 filename: &HgPath,
209 201 ) -> Result<bool, DirstateError> {
210 let old_state = match self.get(filename) {
211 Some(e) => e.state(),
212 None => EntryState::Unknown,
213 };
202 let old_state = self.get(filename).map(|e| e.state());
214 203 let exists = self.state_map.remove(filename).is_some();
215 204
216 205 if exists {
217 if old_state != EntryState::Removed {
206 if old_state != Some(EntryState::Removed) {
218 207 if let Some(ref mut dirs) = self.dirs {
219 208 dirs.delete_path(filename)?;
220 209 }
@@ -7,7 +7,6 b' pub enum EntryState {'
7 7 Added,
8 8 Removed,
9 9 Merged,
10 Unknown,
11 10 }
12 11
13 12 /// The C implementation uses all signed types. This will be an issue
@@ -157,7 +156,7 b' impl EntryState {'
157 156 use EntryState::*;
158 157 match self {
159 158 Normal | Added | Merged => true,
160 Removed | Unknown => false,
159 Removed => false,
161 160 }
162 161 }
163 162 }
@@ -171,7 +170,6 b' impl TryFrom<u8> for EntryState {'
171 170 b'a' => Ok(EntryState::Added),
172 171 b'r' => Ok(EntryState::Removed),
173 172 b'm' => Ok(EntryState::Merged),
174 b'?' => Ok(EntryState::Unknown),
175 173 _ => Err(HgError::CorruptedRepository(format!(
176 174 "Incorrect dirstate entry state {}",
177 175 value
@@ -187,7 +185,6 b' impl Into<u8> for EntryState {'
187 185 EntryState::Added => b'a',
188 186 EntryState::Removed => b'r',
189 187 EntryState::Merged => b'm',
190 EntryState::Unknown => b'?',
191 188 }
192 189 }
193 190 }
@@ -205,7 +205,6 b' fn dispatch_found('
205 205 EntryState::Merged => Dispatch::Modified,
206 206 EntryState::Added => Dispatch::Added,
207 207 EntryState::Removed => Dispatch::Removed,
208 EntryState::Unknown => Dispatch::Unknown,
209 208 }
210 209 }
211 210
@@ -218,8 +217,6 b' fn dispatch_missing(state: EntryState) -'
218 217 }
219 218 // File was removed, everything is normal
220 219 EntryState::Removed => Dispatch::Removed,
221 // File is unknown to Mercurial, everything is normal
222 EntryState::Unknown => Dispatch::Unknown,
223 220 }
224 221 }
225 222
@@ -593,12 +593,13 b" impl<'on_disk> DirstateMap<'on_disk> {"
593 593 fn add_or_remove_file(
594 594 &mut self,
595 595 path: &HgPath,
596 old_state: EntryState,
596 old_state: Option<EntryState>,
597 597 new_entry: DirstateEntry,
598 598 ) -> Result<(), DirstateV2ParseError> {
599 let had_entry = old_state != EntryState::Unknown;
599 let had_entry = old_state.is_some();
600 let was_tracked = old_state.map_or(false, |s| s.is_tracked());
600 601 let tracked_count_increment =
601 match (old_state.is_tracked(), new_entry.state().is_tracked()) {
602 match (was_tracked, new_entry.state().is_tracked()) {
602 603 (false, true) => 1,
603 604 (true, false) => -1,
604 605 _ => 0,
@@ -808,10 +809,7 b" impl<'on_disk> super::dispatch::Dirstate"
808 809 let mode = entry.mode();
809 810 let entry = DirstateEntry::from_v1_data(state, mode, size, mtime);
810 811
811 let old_state = match self.get(filename)? {
812 Some(e) => e.state(),
813 None => EntryState::Unknown,
814 };
812 let old_state = self.get(filename)?.map(|e| e.state());
815 813
816 814 Ok(self.add_or_remove_file(filename, old_state, entry)?)
817 815 }
@@ -822,10 +820,7 b" impl<'on_disk> super::dispatch::Dirstate"
822 820 in_merge: bool,
823 821 ) -> Result<(), DirstateError> {
824 822 let old_entry_opt = self.get(filename)?;
825 let old_state = match old_entry_opt {
826 Some(e) => e.state(),
827 None => EntryState::Unknown,
828 };
823 let old_state = old_entry_opt.map(|e| e.state());
829 824 let mut size = 0;
830 825 if in_merge {
831 826 // XXX we should not be able to have 'm' state and 'FROM_P2' if not
@@ -852,10 +847,9 b" impl<'on_disk> super::dispatch::Dirstate"
852 847 }
853 848
854 849 fn drop_file(&mut self, filename: &HgPath) -> Result<bool, DirstateError> {
855 let old_state = match self.get(filename)? {
856 Some(e) => e.state(),
857 None => EntryState::Unknown,
858 };
850 let was_tracked = self
851 .get(filename)?
852 .map_or(false, |e| e.state().is_tracked());
859 853 struct Dropped {
860 854 was_tracked: bool,
861 855 had_entry: bool,
@@ -955,7 +949,7 b" impl<'on_disk> super::dispatch::Dirstate"
955 949 }
956 950 Ok(dropped.had_entry)
957 951 } else {
958 debug_assert!(!old_state.is_tracked());
952 debug_assert!(!was_tracked);
959 953 Ok(false)
960 954 }
961 955 }
@@ -394,9 +394,6 b" impl<'a, 'tree, 'on_disk> StatusCommon<'"
394 394 .push(hg_path.detach_from_tree()),
395 395 EntryState::Normal => self
396 396 .handle_normal_file(&dirstate_node, fs_metadata)?,
397 // This variant is not used in DirstateMap
398 // nodes
399 EntryState::Unknown => unreachable!(),
400 397 }
401 398 } else {
402 399 // `node.entry.is_none()` indicates a "directory"
General Comments 0
You need to be logged in to leave comments. Login now