##// END OF EJS Templates
copies: rearrange all value comparison conditional...
marmoute -
r47309:c692384b default
parent child Browse files
Show More
@@ -481,32 +481,60 b' def _merge_copies_dict(minor, major, isa'
481
481
482
482
483 def _compare_values(changes, isancestor, dest, minor, major):
483 def _compare_values(changes, isancestor, dest, minor, major):
484 """compare two value within a _merge_copies_dict loop iteration"""
484 """compare two value within a _merge_copies_dict loop iteration
485
486 return pick
487
488 - pick is one of PICK_MINOR, PICK_MAJOR or PICK_EITHER
489 """
485 major_tt, major_value = major
490 major_tt, major_value = major
486 minor_tt, minor_value = minor
491 minor_tt, minor_value = minor
487
492
488 # evacuate some simple case first:
489 if major_tt == minor_tt:
493 if major_tt == minor_tt:
490 # if it comes from the same revision it must be the same value
494 # if it comes from the same revision it must be the same value
491 assert major_value == minor_value
495 assert major_value == minor_value
492 return PICK_EITHER
496 return PICK_EITHER
493 elif major[1] == minor[1]:
497 elif (
494 return PICK_EITHER
498 changes is not None
495
499 and minor_value is not None
496 # actual merging needed: content from "major" wins, unless it is older than
500 and major_value is None
497 # the branch point or there is a merge
501 and dest in changes.salvaged
498 elif changes is not None and major[1] is None and dest in changes.salvaged:
502 ):
503 # In this case, a deletion was reverted, the "alive" value overwrite
504 # the deleted one.
499 return PICK_MINOR
505 return PICK_MINOR
500 elif changes is not None and minor[1] is None and dest in changes.salvaged:
506 elif (
507 changes is not None
508 and major_value is not None
509 and minor_value is None
510 and dest in changes.salvaged
511 ):
512 # In this case, a deletion was reverted, the "alive" value overwrite
513 # the deleted one.
501 return PICK_MAJOR
514 return PICK_MAJOR
502 elif changes is not None and dest in changes.merged:
515 elif isancestor(minor_tt, major_tt):
516 if changes is not None and dest in changes.merged:
517 # change to dest happened on the branch without copy-source change,
518 # so both source are valid and "major" wins.
519 return PICK_MAJOR
520 else:
521 return PICK_MAJOR
522 elif isancestor(major_tt, minor_tt):
523 if changes is not None and dest in changes.merged:
524 # change to dest happened on the branch without copy-source change,
525 # so both source are valid and "major" wins.
526 return PICK_MAJOR
527 else:
528 return PICK_MINOR
529 elif minor_value is None:
530 # in case of conflict, the "alive" side wins.
503 return PICK_MAJOR
531 return PICK_MAJOR
504 elif not isancestor(major_tt, minor_tt):
532 elif major_value is None:
505 if major[1] is not None:
533 # in case of conflict, the "alive" side wins.
506 return PICK_MAJOR
534 return PICK_MINOR
507 elif isancestor(minor_tt, major_tt):
535 else:
508 return PICK_MAJOR
536 # in case of conflict where both side are alive, major wins.
509 return PICK_MINOR
537 return PICK_MAJOR
510
538
511
539
512 def _revinfo_getter_extra(repo):
540 def _revinfo_getter_extra(repo):
@@ -746,6 +746,8 b' fn compare_value<A: Fn(Revision, Revisio'
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 }
@@ -753,45 +755,61 b' fn compare_value<A: Fn(Revision, Revisio'
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 {
774 MergePick::Major
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 }
775 } else if oracle.is_overwrite(src_major.rev, src_minor.rev) {
792 } else if oracle.is_overwrite(src_major.rev, src_minor.rev) {
776 // If the minor side is strictly newer than the major
793 if action == MergeCase::Merged {
777 // side, it should be kept.
794 // If the file was actively merged, its means some non-copy
778 MergePick::Minor
795 // activity happened on the other branch. It
779 } else if src_major.path.is_some() {
796 // mean the older copy information are still relevant.
780 // without any special case, the "major" value win
797 //
781 // other the "minor" one.
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
782 MergePick::Major
806 MergePick::Major
783 } else if oracle.is_overwrite(src_minor.rev, src_major.rev) {
807 } else if src_major.path.is_none() {
784 // the "major" rev is a direct ancestors of "minor",
808 // the major side has no relevant information, pick the alive one
785 // any different value should
809 MergePick::Minor
786 // overwrite
787 MergePick::Major
788 } else {
810 } else {
789 // major version is None (so the file was deleted on
811 // by default the major side wins
790 // that branch) and that branch is independant (neither
812 MergePick::Major
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 }
813 }
796 }
814 }
797 }
815 }
General Comments 0
You need to be logged in to leave comments. Login now