14 pub type PathCopies = HashMap<HgPathBuf, HgPathBuf>; |
14 pub type PathCopies = HashMap<HgPathBuf, HgPathBuf>; |
15 |
15 |
16 type PathToken = usize; |
16 type PathToken = usize; |
17 |
17 |
18 #[derive(Clone, Debug, PartialEq, Copy)] |
18 #[derive(Clone, Debug, PartialEq, Copy)] |
19 struct TimeStampedPathCopy { |
19 struct CopySource { |
20 /// revision at which the copy information was added |
20 /// revision at which the copy information was added |
21 rev: Revision, |
21 rev: Revision, |
22 /// the copy source, (Set to None in case of deletion of the associated |
22 /// the copy source, (Set to None in case of deletion of the associated |
23 /// key) |
23 /// key) |
24 path: Option<PathToken>, |
24 path: Option<PathToken>, |
25 } |
25 } |
26 |
26 |
27 /// maps CopyDestination to Copy Source (+ a "timestamp" for the operation) |
27 /// maps CopyDestination to Copy Source (+ a "timestamp" for the operation) |
28 type InternalPathCopies = OrdMap<PathToken, TimeStampedPathCopy>; |
28 type InternalPathCopies = OrdMap<PathToken, CopySource>; |
29 |
29 |
30 /// hold parent 1, parent 2 and relevant files actions. |
30 /// hold parent 1, parent 2 and relevant files actions. |
31 pub type RevInfo<'a> = (Revision, Revision, ChangedFiles<'a>); |
31 pub type RevInfo<'a> = (Revision, Revision, ChangedFiles<'a>); |
32 |
32 |
33 /// represent the files affected by a changesets |
33 /// represent the files affected by a changesets |
519 // record this information as we will need it to take |
519 // record this information as we will need it to take |
520 // the right decision when merging conflicting copy |
520 // the right decision when merging conflicting copy |
521 // information. See merge_copies_dict for details. |
521 // information. See merge_copies_dict for details. |
522 match copies.entry(dest) { |
522 match copies.entry(dest) { |
523 Entry::Vacant(slot) => { |
523 Entry::Vacant(slot) => { |
524 let ttpc = TimeStampedPathCopy { |
524 let ttpc = CopySource { |
525 rev: current_rev, |
525 rev: current_rev, |
526 path: entry, |
526 path: entry, |
527 }; |
527 }; |
528 slot.insert(ttpc); |
528 slot.insert(ttpc); |
529 } |
529 } |
568 // This closure exist as temporary help while multiple developper are |
568 // This closure exist as temporary help while multiple developper are |
569 // actively working on this code. Feel free to re-inline it once this |
569 // actively working on this code. Feel free to re-inline it once this |
570 // code is more settled. |
570 // code is more settled. |
571 let cmp_value = |oracle: &mut AncestorOracle<A>, |
571 let cmp_value = |oracle: &mut AncestorOracle<A>, |
572 dest: &PathToken, |
572 dest: &PathToken, |
573 src_minor: &TimeStampedPathCopy, |
573 src_minor: &CopySource, |
574 src_major: &TimeStampedPathCopy| { |
574 src_major: &CopySource| { |
575 compare_value( |
575 compare_value( |
576 path_map, |
576 path_map, |
577 current_merge, |
577 current_merge, |
578 changes, |
578 changes, |
579 oracle, |
579 oracle, |
617 let path = match pick { |
617 let path = match pick { |
618 MergePick::Major => src_major.path, |
618 MergePick::Major => src_major.path, |
619 MergePick::Minor => src_minor.path, |
619 MergePick::Minor => src_minor.path, |
620 MergePick::Any => src_major.path, |
620 MergePick::Any => src_major.path, |
621 }; |
621 }; |
622 let src = TimeStampedPathCopy { |
622 let src = CopySource { |
623 rev: current_merge, |
623 rev: current_merge, |
624 path, |
624 path, |
625 }; |
625 }; |
626 major.insert(dest, src); |
626 major.insert(dest, src); |
627 } else { |
627 } else { |
652 let path = match pick { |
652 let path = match pick { |
653 MergePick::Major => src_minor.path, |
653 MergePick::Major => src_minor.path, |
654 MergePick::Minor => src_major.path, |
654 MergePick::Minor => src_major.path, |
655 MergePick::Any => src_major.path, |
655 MergePick::Any => src_major.path, |
656 }; |
656 }; |
657 let src = TimeStampedPathCopy { |
657 let src = CopySource { |
658 rev: current_merge, |
658 rev: current_merge, |
659 path, |
659 path, |
660 }; |
660 }; |
661 minor.insert(dest, src); |
661 minor.insert(dest, src); |
662 } else { |
662 } else { |
671 minor |
671 minor |
672 } else { |
672 } else { |
673 let mut override_minor = Vec::new(); |
673 let mut override_minor = Vec::new(); |
674 let mut override_major = Vec::new(); |
674 let mut override_major = Vec::new(); |
675 |
675 |
676 let mut to_major = |k: &PathToken, v: &TimeStampedPathCopy| { |
676 let mut to_major = |k: &PathToken, v: &CopySource| { |
677 override_major.push((k.clone(), v.clone())) |
677 override_major.push((k.clone(), v.clone())) |
678 }; |
678 }; |
679 let mut to_minor = |k: &PathToken, v: &TimeStampedPathCopy| { |
679 let mut to_minor = |k: &PathToken, v: &CopySource| { |
680 override_minor.push((k.clone(), v.clone())) |
680 override_minor.push((k.clone(), v.clone())) |
681 }; |
681 }; |
682 |
682 |
683 // The diff function leverage detection of the identical subpart if |
683 // The diff function leverage detection of the identical subpart if |
684 // minor and major has some common ancestors. This make it very |
684 // minor and major has some common ancestors. This make it very |
711 MergePick::Minor => src_minor.path, |
711 MergePick::Minor => src_minor.path, |
712 // If the two entry are identical, no need to do |
712 // If the two entry are identical, no need to do |
713 // anything (but diff should not have yield them) |
713 // anything (but diff should not have yield them) |
714 MergePick::Any => src_major.path, |
714 MergePick::Any => src_major.path, |
715 }; |
715 }; |
716 let src = TimeStampedPathCopy { |
716 let src = CopySource { |
717 rev: current_merge, |
717 rev: current_merge, |
718 path, |
718 path, |
719 }; |
719 }; |
720 to_minor(dest, &src); |
720 to_minor(dest, &src); |
721 to_major(dest, &src); |
721 to_major(dest, &src); |
771 path_map: &TwoWayPathMap, |
771 path_map: &TwoWayPathMap, |
772 current_merge: Revision, |
772 current_merge: Revision, |
773 changes: &ChangedFiles, |
773 changes: &ChangedFiles, |
774 oracle: &mut AncestorOracle<A>, |
774 oracle: &mut AncestorOracle<A>, |
775 dest: &PathToken, |
775 dest: &PathToken, |
776 src_minor: &TimeStampedPathCopy, |
776 src_minor: &CopySource, |
777 src_major: &TimeStampedPathCopy, |
777 src_major: &CopySource, |
778 ) -> (MergePick, bool) { |
778 ) -> (MergePick, bool) { |
779 if src_major.rev == current_merge { |
779 if src_major.rev == current_merge { |
780 if src_minor.rev == current_merge { |
780 if src_minor.rev == current_merge { |
781 if src_major.path.is_none() { |
781 if src_major.path.is_none() { |
782 // We cannot get different copy information for both p1 and p2 |
782 // We cannot get different copy information for both p1 and p2 |