744 if src_major.rev == src_minor.rev { |
744 if src_major.rev == src_minor.rev { |
745 // If the two entry are identical, they are both valid |
745 // If the two entry are identical, they are both valid |
746 MergePick::Any |
746 MergePick::Any |
747 } else if oracle.is_overwrite(src_major.rev, src_minor.rev) { |
747 } else if oracle.is_overwrite(src_major.rev, src_minor.rev) { |
748 MergePick::Minor |
748 MergePick::Minor |
|
749 } else if oracle.is_overwrite(src_minor.rev, src_major.rev) { |
|
750 MergePick::Major |
749 } else { |
751 } else { |
750 MergePick::Major |
752 MergePick::Major |
751 } |
753 } |
752 } else if src_major.rev == src_minor.rev { |
754 } else if src_major.rev == src_minor.rev { |
753 // We cannot get copy information for both p1 and p2 in the |
755 // We cannot get copy information for both p1 and p2 in the |
754 // same rev. So this is the same value. |
756 // same rev. So this is the same value. |
755 unreachable!( |
757 unreachable!( |
756 "conflict information from p1 and p2 in the same revision" |
758 "conflicting information from p1 and p2 in the same revision" |
757 ); |
759 ); |
758 } else { |
760 } else { |
759 let dest_path = path_map.untokenize(*dest); |
761 let dest_path = path_map.untokenize(*dest); |
760 let action = changes.get_merge_case(dest_path); |
762 let action = changes.get_merge_case(dest_path); |
761 if src_major.path.is_none() && action == MergeCase::Salvaged { |
763 if src_minor.path.is_some() |
|
764 && src_major.path.is_none() |
|
765 && action == MergeCase::Salvaged |
|
766 { |
762 // If the file is "deleted" in the major side but was |
767 // If the file is "deleted" in the major side but was |
763 // salvaged by the merge, we keep the minor side alive |
768 // salvaged by the merge, we keep the minor side alive |
764 MergePick::Minor |
769 MergePick::Minor |
765 } else if src_minor.path.is_none() && action == MergeCase::Salvaged { |
770 } else if src_major.path.is_some() |
|
771 && src_minor.path.is_none() |
|
772 && action == MergeCase::Salvaged |
|
773 { |
766 // If the file is "deleted" in the minor side but was |
774 // If the file is "deleted" in the minor side but was |
767 // salvaged by the merge, unconditionnaly preserve the |
775 // salvaged by the merge, unconditionnaly preserve the |
768 // major side. |
776 // major side. |
769 MergePick::Major |
777 MergePick::Major |
770 } else if action == MergeCase::Merged { |
778 } else if oracle.is_overwrite(src_minor.rev, src_major.rev) { |
771 // If the file was actively merged, copy information |
779 // The information from the minor version are strictly older than |
772 // from each side might conflict. The major side will |
780 // the major version |
773 // win such conflict. |
781 if action == MergeCase::Merged { |
|
782 // If the file was actively merged, its means some non-copy |
|
783 // activity happened on the other branch. It |
|
784 // mean the older copy information are still relevant. |
|
785 // |
|
786 // The major side wins such conflict. |
|
787 MergePick::Major |
|
788 } else { |
|
789 // No activity on the minor branch, pick the newer one. |
|
790 MergePick::Major |
|
791 } |
|
792 } else if oracle.is_overwrite(src_major.rev, src_minor.rev) { |
|
793 if action == MergeCase::Merged { |
|
794 // If the file was actively merged, its means some non-copy |
|
795 // activity happened on the other branch. It |
|
796 // mean the older copy information are still relevant. |
|
797 // |
|
798 // The major side wins such conflict. |
|
799 MergePick::Major |
|
800 } else { |
|
801 // No activity on the minor branch, pick the newer one. |
|
802 MergePick::Minor |
|
803 } |
|
804 } else if src_minor.path.is_none() { |
|
805 // the minor side has no relevant information, pick the alive one |
774 MergePick::Major |
806 MergePick::Major |
775 } else if oracle.is_overwrite(src_major.rev, src_minor.rev) { |
807 } else if src_major.path.is_none() { |
776 // If the minor side is strictly newer than the major |
808 // the major side has no relevant information, pick the alive one |
777 // side, it should be kept. |
|
778 MergePick::Minor |
809 MergePick::Minor |
779 } else if src_major.path.is_some() { |
810 } else { |
780 // without any special case, the "major" value win |
811 // by default the major side wins |
781 // other the "minor" one. |
|
782 MergePick::Major |
812 MergePick::Major |
783 } else if oracle.is_overwrite(src_minor.rev, src_major.rev) { |
813 } |
784 // the "major" rev is a direct ancestors of "minor", |
814 } |
785 // any different value should |
815 } |
786 // overwrite |
|
787 MergePick::Major |
|
788 } else { |
|
789 // major version is None (so the file was deleted on |
|
790 // that branch) and that branch is independant (neither |
|
791 // minor nor major is an ancestors of the other one.) |
|
792 // We preserve the new |
|
793 // information about the new file. |
|
794 MergePick::Minor |
|
795 } |
|
796 } |
|
797 } |
|