/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-29 20:41:35 UTC
  • mto: (3697.7.4 1.7)
  • mto: This revision was merged to the branch mainline in revision 3748.
  • Revision ID: john@arbash-meinel.com-20080729204135-hqpkdfp9w6yxtu55
Add the _lca_multi_way function, and explicit tests.

There may be some other edge cases, but I think I covered them all.

Show diffs side-by-side

added added

removed removed

Lines of Context:
706
706
                # of this entry hasn't changed, so skip it.
707
707
                continue
708
708
 
 
709
            is_content_changed = False
 
710
            if kind_changed:
 
711
                is_content_changed = True
 
712
 
709
713
            if file_id in base_inventory:
710
714
                base_ie = self.base_tree.inventory[file_id]
711
715
                base_parent_id = base_ie.parent_id
721
725
            else:
722
726
                this_parent_id = this_name = this_executable = None
723
727
 
 
728
 
724
729
            lca_parent_ids = []
725
730
            lca_names = []
726
731
            lca_executable = []
837
842
            return "other"
838
843
 
839
844
    @staticmethod
 
845
    def _lca_multi_way(bases, other, this):
 
846
        """Consider LCAs when determining whether a change has occurred.
 
847
 
 
848
        If LCAS are all identical, this is the same as a _three_way comparison.
 
849
 
 
850
        :param bases: value in (BASE, [LCAS])
 
851
        :param other: value in OTHER
 
852
        :param this: value in THIS
 
853
        :return: 'this', 'other', or 'conflict' depending on whether an entry
 
854
            changed or not.
 
855
        """
 
856
        if other == this:
 
857
            # Either Ambiguously clean, or nothing was actually changed. We
 
858
            # don't really care
 
859
            return 'this'
 
860
        base_val, lca_vals = bases
 
861
        # Remove 'base_val' from the lca_vals, because it is not interesting
 
862
        filtered_lca_vals = [lca_val for lca_val in lca_vals
 
863
                                      if lca_val != base_val]
 
864
        if len(filtered_lca_vals) == 0:
 
865
            return Merge3Merger._three_way(base_val, other, this)
 
866
        else:
 
867
            first_lca_val = filtered_lca_vals[0]
 
868
            for lca_val in filtered_lca_vals[1:]:
 
869
                if lca_val != first_lca_val:
 
870
                    break
 
871
            else: # all lcas are equal, use 3-way logic
 
872
                return Merge3Merger._three_way(first_lca_val, other, this)
 
873
        if other in filtered_lca_vals:
 
874
            if this in filtered_lca_vals:
 
875
                # Each side picked a different lca, conflict
 
876
                return 'conflict'
 
877
            else:
 
878
                # This has a value which supersedes both lca values, and other
 
879
                # only has an lca value
 
880
                return 'this'
 
881
        elif this in filtered_lca_vals:
 
882
            # OTHER has a value which supersedes both lca values, and this only
 
883
            # has an lca value
 
884
            return 'other'
 
885
 
 
886
        # At this point, the lcas disagree, and the tips disagree
 
887
        return 'conflict'
 
888
 
 
889
    @staticmethod
840
890
    def scalar_three_way(this_tree, base_tree, other_tree, file_id, key):
841
891
        """Do a three-way test on a scalar.
842
892
        Return "this", "other" or "conflict", depending whether a value wins.