##// 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 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 490 major_tt, major_value = major
486 491 minor_tt, minor_value = minor
487 492
488 # evacuate some simple case first:
489 493 if major_tt == minor_tt:
490 494 # if it comes from the same revision it must be the same value
491 495 assert major_value == minor_value
492 496 return PICK_EITHER
493 elif major[1] == minor[1]:
494 return PICK_EITHER
495
496 # actual merging needed: content from "major" wins, unless it is older than
497 # the branch point or there is a merge
498 elif changes is not None and major[1] is None and dest in changes.salvaged:
497 elif (
498 changes is not None
499 and minor_value is not None
500 and major_value is None
501 and dest in changes.salvaged
502 ):
503 # In this case, a deletion was reverted, the "alive" value overwrite
504 # the deleted one.
499 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 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 531 return PICK_MAJOR
504 elif not isancestor(major_tt, minor_tt):
505 if major[1] is not None:
506 return PICK_MAJOR
507 elif isancestor(minor_tt, major_tt):
508 return PICK_MAJOR
509 return PICK_MINOR
532 elif major_value is None:
533 # in case of conflict, the "alive" side wins.
534 return PICK_MINOR
535 else:
536 # in case of conflict where both side are alive, major wins.
537 return PICK_MAJOR
510 538
511 539
512 540 def _revinfo_getter_extra(repo):
@@ -746,6 +746,8 b' fn compare_value<A: Fn(Revision, Revisio'
746 746 MergePick::Any
747 747 } else if oracle.is_overwrite(src_major.rev, src_minor.rev) {
748 748 MergePick::Minor
749 } else if oracle.is_overwrite(src_minor.rev, src_major.rev) {
750 MergePick::Major
749 751 } else {
750 752 MergePick::Major
751 753 }
@@ -753,45 +755,61 b' fn compare_value<A: Fn(Revision, Revisio'
753 755 // We cannot get copy information for both p1 and p2 in the
754 756 // same rev. So this is the same value.
755 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 760 } else {
759 761 let dest_path = path_map.untokenize(*dest);
760 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 767 // If the file is "deleted" in the major side but was
763 768 // salvaged by the merge, we keep the minor side alive
764 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 774 // If the file is "deleted" in the minor side but was
767 775 // salvaged by the merge, unconditionnaly preserve the
768 776 // major side.
769 777 MergePick::Major
770 } else if action == MergeCase::Merged {
771 // If the file was actively merged, copy information
772 // from each side might conflict. The major side will
773 // win such conflict.
774 MergePick::Major
778 } else if oracle.is_overwrite(src_minor.rev, src_major.rev) {
779 // The information from the minor version are strictly older than
780 // the major version
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 }
775 792 } else if oracle.is_overwrite(src_major.rev, src_minor.rev) {
776 // If the minor side is strictly newer than the major
777 // side, it should be kept.
778 MergePick::Minor
779 } else if src_major.path.is_some() {
780 // without any special case, the "major" value win
781 // other the "minor" one.
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
782 806 MergePick::Major
783 } else if oracle.is_overwrite(src_minor.rev, src_major.rev) {
784 // the "major" rev is a direct ancestors of "minor",
785 // any different value should
786 // overwrite
787 MergePick::Major
807 } else if src_major.path.is_none() {
808 // the major side has no relevant information, pick the alive one
809 MergePick::Minor
788 810 } 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
811 // by default the major side wins
812 MergePick::Major
795 813 }
796 814 }
797 815 }
General Comments 0
You need to be logged in to leave comments. Login now