##// END OF EJS Templates
copies-rust: yield both p1 and p2 copies in `ChangedFiles.actions()`...
marmoute -
r47320:a34cd9aa default
parent child Browse files
Show More
@@ -107,7 +107,8 b" enum Action<'a> {"
107 107 Removed(&'a HgPath),
108 108 /// The parent ? children edge introduce copy information between (dest,
109 109 /// source)
110 Copied(&'a HgPath, &'a HgPath),
110 CopiedFromP1(&'a HgPath, &'a HgPath),
111 CopiedFromP2(&'a HgPath, &'a HgPath),
111 112 }
112 113
113 114 /// This express the possible "special" case we can get in a merge
@@ -246,10 +247,9 b" impl<'a> ChangedFiles<'a> {"
246 247 }
247 248
248 249 /// Return an iterator over all the `Action` in this instance.
249 fn iter_actions(&self, parent: Parent) -> ActionsIterator {
250 fn iter_actions(&self) -> ActionsIterator {
250 251 ActionsIterator {
251 252 changes: &self,
252 parent: parent,
253 253 current: 0,
254 254 }
255 255 }
@@ -283,7 +283,6 b" impl<'a> ChangedFiles<'a> {"
283 283
284 284 struct ActionsIterator<'a> {
285 285 changes: &'a ChangedFiles<'a>,
286 parent: Parent,
287 286 current: u32,
288 287 }
289 288
@@ -291,10 +290,6 b" impl<'a> Iterator for ActionsIterator<'a"
291 290 type Item = Action<'a>;
292 291
293 292 fn next(&mut self) -> Option<Action<'a>> {
294 let copy_flag = match self.parent {
295 Parent::FirstParent => P1_COPY,
296 Parent::SecondParent => P2_COPY,
297 };
298 293 while self.current < self.changes.nb_items {
299 294 let (flags, file, source) = self.changes.entry(self.current);
300 295 self.current += 1;
@@ -302,8 +297,10 b" impl<'a> Iterator for ActionsIterator<'a"
302 297 return Some(Action::Removed(file));
303 298 }
304 299 let copy = flags & COPY_MASK;
305 if copy == copy_flag {
306 return Some(Action::Copied(file, source));
300 if copy == P1_COPY {
301 return Some(Action::CopiedFromP1(file, source));
302 } else if copy == P2_COPY {
303 return Some(Action::CopiedFromP2(file, source));
307 304 }
308 305 }
309 306 return None;
@@ -500,17 +497,33 b' fn add_from_changes('
500 497 current_rev: Revision,
501 498 ) -> InternalPathCopies {
502 499 let mut copies = base_copies.clone();
503 for action in changes.iter_actions(parent) {
500 for action in changes.iter_actions() {
504 501 match action {
505 Action::Copied(path_dest, path_source) => {
506 add_one_copy(
507 current_rev,
508 &mut path_map,
509 &mut copies,
510 &base_copies,
511 path_dest,
512 path_source,
513 );
502 Action::CopiedFromP1(path_dest, path_source) => {
503 match parent {
504 _ => (), // not the parent we are looking for
505 Parent::FirstParent => add_one_copy(
506 current_rev,
507 path_map,
508 &mut copies,
509 &base_copies,
510 path_dest,
511 path_source,
512 ),
513 };
514 }
515 Action::CopiedFromP2(path_dest, path_source) => {
516 match parent {
517 _ => (), //not the parent we are looking for
518 Parent::SecondParent => add_one_copy(
519 current_rev,
520 path_map,
521 &mut copies,
522 &base_copies,
523 path_dest,
524 path_source,
525 ),
526 };
514 527 }
515 528 Action::Removed(deleted_path) => {
516 529 // We must drop copy information for removed file.
General Comments 0
You need to be logged in to leave comments. Login now