~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

Handle additions and modfications

Show diffs side-by-side

added added

removed removed

Lines of Context:
1162
1162
                self.tt.delete_contents(trans_id)
1163
1163
            if file_id in self.other_tree:
1164
1164
                # OTHER changed the file
 
1165
                wt = self.this_tree
 
1166
                if wt.supports_content_filtering():
 
1167
                    # We get the path from the working tree if it exists.
 
1168
                    # That fails though when OTHER is adding a file, so
 
1169
                    # we fall back to the other tree to find the path if
 
1170
                    # it doesn't exist locally.
 
1171
                    try:
 
1172
                        filter_tree_path = wt.id2path(file_id)
 
1173
                    except errors.NoSuchId:
 
1174
                        filter_tree_path = self.other_tree.id2path(file_id)
 
1175
                else:
 
1176
                    # Skip the id2path lookup for older formats
 
1177
                    filter_tree_path = None
1165
1178
                create_from_tree(self.tt, trans_id,
1166
 
                                 self.other_tree, file_id)
 
1179
                                 self.other_tree, file_id,
 
1180
                                 filter_tree_path=filter_tree_path)
1167
1181
                if not file_in_this:
1168
1182
                    self.tt.version_file(file_id, trans_id)
1169
1183
                return "modified"
1256
1270
                ('THIS', self.this_tree, this_lines)]
1257
1271
        if not no_base:
1258
1272
            data.append(('BASE', self.base_tree, base_lines))
 
1273
 
 
1274
        # We need to use the actual path in the working tree of the file here,
 
1275
        # ignoring the conflict suffixes
 
1276
        wt = self.this_tree
 
1277
        if wt.supports_content_filtering():
 
1278
            try:
 
1279
                filter_tree_path = wt.id2path(file_id)
 
1280
            except errors.NoSuchId:
 
1281
                # file has been deleted
 
1282
                filter_tree_path = None
 
1283
        else:
 
1284
            # Skip the id2path lookup for older formats
 
1285
            filter_tree_path = None
 
1286
 
1259
1287
        versioned = False
1260
1288
        file_group = []
1261
1289
        for suffix, tree, lines in data:
1262
1290
            if file_id in tree:
1263
1291
                trans_id = self._conflict_file(name, parent_id, tree, file_id,
1264
 
                                               suffix, lines)
 
1292
                                               suffix, lines, filter_tree_path)
1265
1293
                file_group.append(trans_id)
1266
1294
                if set_version and not versioned:
1267
1295
                    self.tt.version_file(file_id, trans_id)
1269
1297
        return file_group
1270
1298
 
1271
1299
    def _conflict_file(self, name, parent_id, tree, file_id, suffix,
1272
 
                       lines=None):
 
1300
                       lines=None, filter_tree_path=None):
1273
1301
        """Emit a single conflict file."""
1274
1302
        name = name + '.' + suffix
1275
1303
        trans_id = self.tt.create_path(name, parent_id)
1276
 
        create_from_tree(self.tt, trans_id, tree, file_id, lines)
 
1304
        create_from_tree(self.tt, trans_id, tree, file_id, lines,
 
1305
            filter_tree_path)
1277
1306
        return trans_id
1278
1307
 
1279
1308
    def merge_executable(self, file_id, file_status):