~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-27 20:24:43 UTC
  • mfrom: (3960.2.1 1.12-progress-warnings)
  • Revision ID: pqm@pqm.ubuntu.com-20090127202443-ty2bu1hh91dumasz
(jam) Avoid getting a UserWarning by not creating an unused progress
        bar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
977
977
        :return: 'this', 'other', or 'conflict' depending on whether an entry
978
978
            changed or not.
979
979
        """
980
 
        # See doc/developers/lca_tree_merging.txt for details about this
 
980
        # See doc/developers/lca_merge_resolution.txt for details about this
981
981
        # algorithm.
982
982
        if other == this:
983
983
            # Either Ambiguously clean, or nothing was actually changed. We
1118
1118
        # file kind...
1119
1119
        base_pair = contents_pair(self.base_tree)
1120
1120
        other_pair = contents_pair(self.other_tree)
1121
 
        if self._lca_trees:
1122
 
            this_pair = contents_pair(self.this_tree)
1123
 
            lca_pairs = [contents_pair(tree) for tree in self._lca_trees]
1124
 
            winner = self._lca_multi_way((base_pair, lca_pairs), other_pair,
1125
 
                                         this_pair, allow_overriding_lca=False)
1126
 
        else:
1127
 
            if base_pair == other_pair:
1128
 
                winner = 'this'
1129
 
            else:
1130
 
                # We delayed evaluating this_pair as long as we can to avoid
1131
 
                # unnecessary sha1 calculation
1132
 
                this_pair = contents_pair(self.this_tree)
1133
 
                winner = self._three_way(base_pair, other_pair, this_pair)
1134
 
        if winner == 'this':
1135
 
            # No interesting changes introduced by OTHER
1136
 
            return "unmodified"
1137
 
        trans_id = self.tt.trans_id_file_id(file_id)
1138
 
        if winner == 'other':
1139
 
            # OTHER is a straight winner, so replace this contents with other
1140
 
            file_in_this = file_id in self.this_tree
1141
 
            if file_in_this:
1142
 
                # Remove any existing contents
1143
 
                self.tt.delete_contents(trans_id)
1144
 
            if file_id in self.other_tree:
1145
 
                # OTHER changed the file
1146
 
                create_from_tree(self.tt, trans_id,
1147
 
                                 self.other_tree, file_id)
1148
 
                if not file_in_this:
1149
 
                    self.tt.version_file(file_id, trans_id)
1150
 
                return "modified"
1151
 
            elif file_in_this:
1152
 
                # OTHER deleted the file
1153
 
                self.tt.unversion_file(trans_id)
1154
 
                return "deleted"
1155
 
        else:
1156
 
            # We have a hypothetical conflict, but if we have files, then we
1157
 
            # can try to merge the content
1158
 
            if this_pair[0] == 'file' and other_pair[0] == 'file':
 
1121
        if base_pair == other_pair:
 
1122
            # OTHER introduced no changes
 
1123
            return "unmodified"
 
1124
        this_pair = contents_pair(self.this_tree)
 
1125
        if this_pair == other_pair:
 
1126
            # THIS and OTHER introduced the same changes
 
1127
            return "unmodified"
 
1128
        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":
1159
1148
                # THIS and OTHER are both files, so text merge.  Either
1160
1149
                # BASE is a file, or both converted to files, so at least we
1161
1150
                # have agreement that output should be a file.
1172
1161
                    pass
1173
1162
                return "modified"
1174
1163
            else:
 
1164
                # Scalar conflict, can't text merge.  Dump conflicts
1175
1165
                return contents_conflict()
1176
1166
 
1177
1167
    def get_lines(self, tree, file_id):