##// 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 Removed(&'a HgPath),
107 Removed(&'a HgPath),
108 /// The parent ? children edge introduce copy information between (dest,
108 /// The parent ? children edge introduce copy information between (dest,
109 /// source)
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 /// This express the possible "special" case we can get in a merge
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 /// Return an iterator over all the `Action` in this instance.
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 ActionsIterator {
251 ActionsIterator {
251 changes: &self,
252 changes: &self,
252 parent: parent,
253 current: 0,
253 current: 0,
254 }
254 }
255 }
255 }
@@ -283,7 +283,6 b" impl<'a> ChangedFiles<'a> {"
283
283
284 struct ActionsIterator<'a> {
284 struct ActionsIterator<'a> {
285 changes: &'a ChangedFiles<'a>,
285 changes: &'a ChangedFiles<'a>,
286 parent: Parent,
287 current: u32,
286 current: u32,
288 }
287 }
289
288
@@ -291,10 +290,6 b" impl<'a> Iterator for ActionsIterator<'a"
291 type Item = Action<'a>;
290 type Item = Action<'a>;
292
291
293 fn next(&mut self) -> Option<Action<'a>> {
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 while self.current < self.changes.nb_items {
293 while self.current < self.changes.nb_items {
299 let (flags, file, source) = self.changes.entry(self.current);
294 let (flags, file, source) = self.changes.entry(self.current);
300 self.current += 1;
295 self.current += 1;
@@ -302,8 +297,10 b" impl<'a> Iterator for ActionsIterator<'a"
302 return Some(Action::Removed(file));
297 return Some(Action::Removed(file));
303 }
298 }
304 let copy = flags & COPY_MASK;
299 let copy = flags & COPY_MASK;
305 if copy == copy_flag {
300 if copy == P1_COPY {
306 return Some(Action::Copied(file, source));
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 return None;
306 return None;
@@ -500,17 +497,33 b' fn add_from_changes('
500 current_rev: Revision,
497 current_rev: Revision,
501 ) -> InternalPathCopies {
498 ) -> InternalPathCopies {
502 let mut copies = base_copies.clone();
499 let mut copies = base_copies.clone();
503 for action in changes.iter_actions(parent) {
500 for action in changes.iter_actions() {
504 match action {
501 match action {
505 Action::Copied(path_dest, path_source) => {
502 Action::CopiedFromP1(path_dest, path_source) => {
506 add_one_copy(
503 match parent {
507 current_rev,
504 _ => (), // not the parent we are looking for
508 &mut path_map,
505 Parent::FirstParent => add_one_copy(
509 &mut copies,
506 current_rev,
510 &base_copies,
507 path_map,
511 path_dest,
508 &mut copies,
512 path_source,
509 &base_copies,
513 );
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 Action::Removed(deleted_path) => {
528 Action::Removed(deleted_path) => {
516 // We must drop copy information for removed file.
529 // We must drop copy information for removed file.
General Comments 0
You need to be logged in to leave comments. Login now