##// END OF EJS Templates
rust-dirstatemap: directly return `non_normal` and `other_entries`...
Raphaël Gomès -
r44842:c089a094 default
parent child Browse files
Show More
@@ -100,16 +100,12 b' impl DirstateMap {'
100 if entry.state != EntryState::Normal || entry.mtime == MTIME_UNSET {
100 if entry.state != EntryState::Normal || entry.mtime == MTIME_UNSET {
101 self.get_non_normal_other_parent_entries()
101 self.get_non_normal_other_parent_entries()
102 .0
102 .0
103 .as_mut()
104 .unwrap()
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.size == SIZE_FROM_OTHER_PARENT {
109 self.get_non_normal_other_parent_entries()
107 self.get_non_normal_other_parent_entries()
110 .1
108 .1
111 .as_mut()
112 .unwrap()
113 .insert(filename.to_owned());
109 .insert(filename.to_owned());
114 }
110 }
115 Ok(())
111 Ok(())
@@ -152,8 +148,6 b' impl DirstateMap {'
152 );
148 );
153 self.get_non_normal_other_parent_entries()
149 self.get_non_normal_other_parent_entries()
154 .0
150 .0
155 .as_mut()
156 .unwrap()
157 .insert(filename.to_owned());
151 .insert(filename.to_owned());
158 Ok(())
152 Ok(())
159 }
153 }
@@ -182,8 +176,6 b' impl DirstateMap {'
182 }
176 }
183 self.get_non_normal_other_parent_entries()
177 self.get_non_normal_other_parent_entries()
184 .0
178 .0
185 .as_mut()
186 .unwrap()
187 .remove(filename);
179 .remove(filename);
188
180
189 Ok(exists)
181 Ok(exists)
@@ -211,8 +203,6 b' impl DirstateMap {'
211 if changed {
203 if changed {
212 self.get_non_normal_other_parent_entries()
204 self.get_non_normal_other_parent_entries()
213 .0
205 .0
214 .as_mut()
215 .unwrap()
216 .insert(filename.to_owned());
206 .insert(filename.to_owned());
217 }
207 }
218 }
208 }
@@ -224,8 +214,6 b' impl DirstateMap {'
224 ) -> bool {
214 ) -> bool {
225 self.get_non_normal_other_parent_entries()
215 self.get_non_normal_other_parent_entries()
226 .0
216 .0
227 .as_mut()
228 .unwrap()
229 .remove(key.as_ref())
217 .remove(key.as_ref())
230 }
218 }
231 pub fn non_normal_entries_union(
219 pub fn non_normal_entries_union(
@@ -234,8 +222,6 b' impl DirstateMap {'
234 ) -> Vec<HgPathBuf> {
222 ) -> Vec<HgPathBuf> {
235 self.get_non_normal_other_parent_entries()
223 self.get_non_normal_other_parent_entries()
236 .0
224 .0
237 .as_mut()
238 .unwrap()
239 .union(&other)
225 .union(&other)
240 .map(|e| e.to_owned())
226 .map(|e| e.to_owned())
241 .collect()
227 .collect()
@@ -243,12 +229,12 b' impl DirstateMap {'
243
229
244 pub fn get_non_normal_other_parent_entries(
230 pub fn get_non_normal_other_parent_entries(
245 &mut self,
231 &mut self,
246 ) -> (
232 ) -> (&mut HashSet<HgPathBuf>, &mut HashSet<HgPathBuf>) {
247 &mut Option<HashSet<HgPathBuf>>,
248 &mut Option<HashSet<HgPathBuf>>,
249 ) {
250 self.set_non_normal_other_parent_entries(false);
233 self.set_non_normal_other_parent_entries(false);
251 (&mut self.non_normal_set, &mut self.other_parent_set)
234 (
235 self.non_normal_set.as_mut().unwrap(),
236 self.other_parent_set.as_mut().unwrap(),
237 )
252 }
238 }
253
239
254 pub fn set_non_normal_other_parent_entries(&mut self, force: bool) {
240 pub fn set_non_normal_other_parent_entries(&mut self, force: bool) {
@@ -440,22 +426,8 b' mod tests {'
440 .unwrap();
426 .unwrap();
441
427
442 assert_eq!(1, map.len());
428 assert_eq!(1, map.len());
443 assert_eq!(
429 assert_eq!(0, map.get_non_normal_other_parent_entries().0.len());
444 0,
430 assert_eq!(0, map.get_non_normal_other_parent_entries().1.len());
445 map.get_non_normal_other_parent_entries()
446 .0
447 .as_ref()
448 .unwrap()
449 .len()
450 );
451 assert_eq!(
452 0,
453 map.get_non_normal_other_parent_entries()
454 .1
455 .as_ref()
456 .unwrap()
457 .len()
458 );
459 }
431 }
460
432
461 #[test]
433 #[test]
@@ -487,7 +459,7 b' mod tests {'
487 })
459 })
488 .collect();
460 .collect();
489
461
490 let non_normal = [
462 let mut non_normal = [
491 b"f1", b"f2", b"f5", b"f6", b"f7", b"f8", b"f9", b"fa", b"fb",
463 b"f1", b"f2", b"f5", b"f6", b"f7", b"f8", b"f9", b"fa", b"fb",
492 ]
464 ]
493 .iter()
465 .iter()
@@ -499,8 +471,8 b' mod tests {'
499 let entries = map.get_non_normal_other_parent_entries();
471 let entries = map.get_non_normal_other_parent_entries();
500
472
501 assert_eq!(
473 assert_eq!(
502 (Some(non_normal), Some(other_parent)),
474 (&mut non_normal, &mut other_parent),
503 (entries.0.to_owned(), entries.1.to_owned())
475 (entries.0, entries.1)
504 );
476 );
505 }
477 }
506 }
478 }
@@ -175,8 +175,7 b' py_class!(pub class DirstateMap |py| {'
175 locals.set_item(
175 locals.set_item(
176 py,
176 py,
177 "other_parent",
177 "other_parent",
178 other_parent.as_ref()
178 other_parent
179 .unwrap()
180 .iter()
179 .iter()
181 .map(|v| PyBytes::new(py, v.as_ref()))
180 .map(|v| PyBytes::new(py, v.as_ref()))
182 .collect::<Vec<PyBytes>>()
181 .collect::<Vec<PyBytes>>()
@@ -196,8 +195,6 b' py_class!(pub class DirstateMap |py| {'
196 .inner(py)
195 .inner(py)
197 .borrow_mut()
196 .borrow_mut()
198 .get_non_normal_other_parent_entries().0
197 .get_non_normal_other_parent_entries().0
199 .as_ref()
200 .unwrap()
201 .contains(HgPath::new(key.data(py))))
198 .contains(HgPath::new(key.data(py))))
202 }
199 }
203
200
@@ -211,8 +208,7 b' py_class!(pub class DirstateMap |py| {'
211 .inner(py)
208 .inner(py)
212 .borrow_mut()
209 .borrow_mut()
213 .get_non_normal_other_parent_entries().0
210 .get_non_normal_other_parent_entries().0
214 .as_ref()
211 .iter().map(|o| o))
215 .unwrap().iter().map(|o| o))
216 )
212 )
217 )
213 )
218 }
214 }
General Comments 0
You need to be logged in to leave comments. Login now