/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: 2009-01-23 16:54:53 UTC
  • mto: (3948.1.6 spurious-conflicts)
  • mto: This revision was merged to the branch mainline in revision 3967.
  • Revision ID: john@arbash-meinel.com-20090123165453-uh76h1nfqzshc707
Change the workings of merge_content to be lca aware.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1118
1118
        # file kind...
1119
1119
        base_pair = contents_pair(self.base_tree)
1120
1120
        other_pair = contents_pair(self.other_tree)
1121
 
        if base_pair == other_pair:
1122
 
            # OTHER introduced no changes
1123
 
            return "unmodified"
 
1121
        # TODO: we could evaluate this only after evaluating base vs other vs
 
1122
        #       lcas, as at least some of the time it isn't needed
1124
1123
        this_pair = contents_pair(self.this_tree)
1125
 
        if this_pair == other_pair:
1126
 
            # THIS and OTHER introduced the same changes
 
1124
        if self._lca_trees:
 
1125
            lca_pairs = [contents_pair(tree) for tree in self._lca_trees]
 
1126
            winner = self._lca_multi_way((base_pair, lca_pairs), other_pair,
 
1127
                                         this_pair, allow_overriding_lca=False)
 
1128
        else:
 
1129
            winner = self._three_way(base_pair, other_pair, this_pair)
 
1130
        if winner == 'this':
 
1131
            # No interesting changes introduced by OTHER
1127
1132
            return "unmodified"
 
1133
        trans_id = self.tt.trans_id_file_id(file_id)
 
1134
        if winner == 'other':
 
1135
            # OTHER is a straight winner, so replace this contents with other
 
1136
            if file_id in self.this_tree:
 
1137
                # Remove any existing contents
 
1138
                self.tt.delete_contents(trans_id)
 
1139
            # XXX: why do we use file_id in self.other_tree, but then use
 
1140
            if file_id in self.other_tree:
 
1141
                # OTHER changed the file
 
1142
                create_from_tree(self.tt, trans_id,
 
1143
                                 self.other_tree, file_id)
 
1144
                if file_id not in self.this_tree:
 
1145
                    self.tt.version_file(file_id, trans_id)
 
1146
                return "modified"
 
1147
            elif file_id in self.this_tree:
 
1148
                # OTHER deleted the file
 
1149
                self.tt.unversion_file(trans_id)
 
1150
                return "deleted"
1128
1151
        else:
1129
 
            trans_id = self.tt.trans_id_file_id(file_id)
1130
 
            if this_pair == base_pair:
1131
 
                # only OTHER introduced changes
1132
 
                if file_id in self.this_tree:
1133
 
                    # Remove any existing contents
1134
 
                    self.tt.delete_contents(trans_id)
1135
 
                if file_id in self.other_tree:
1136
 
                    # OTHER changed the file
1137
 
                    create_from_tree(self.tt, trans_id,
1138
 
                                     self.other_tree, file_id)
1139
 
                    if file_id not in self.this_tree:
1140
 
                        self.tt.version_file(file_id, trans_id)
1141
 
                    return "modified"
1142
 
                elif file_id in self.this_tree.inventory:
1143
 
                    # OTHER deleted the file
1144
 
                    self.tt.unversion_file(trans_id)
1145
 
                    return "deleted"
1146
 
            #BOTH THIS and OTHER introduced changes; scalar conflict
1147
 
            elif this_pair[0] == "file" and other_pair[0] == "file":
 
1152
            # We have a hypothetical conflict, but if we have files, then we
 
1153
            # can try to merge the content
 
1154
            assert winner == 'conflict'
 
1155
            if this_pair[0] == 'file' and other_pair[0] == 'file':
1148
1156
                # THIS and OTHER are both files, so text merge.  Either
1149
1157
                # BASE is a file, or both converted to files, so at least we
1150
1158
                # have agreement that output should be a file.
1161
1169
                    pass
1162
1170
                return "modified"
1163
1171
            else:
1164
 
                # Scalar conflict, can't text merge.  Dump conflicts
1165
1172
                return contents_conflict()
1166
1173
 
1167
1174
    def get_lines(self, tree, file_id):