/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 breezy/merge.py

Avoid dealing with file ids if possible.

Merged from https://code.launchpad.net/~jelmer/brz/merge-avoid-file-id/+merge/388959

Show diffs side-by-side

added added

removed removed

Lines of Context:
1306
1306
                # This is a contents conflict, because none of the available
1307
1307
                # functions could merge it.
1308
1308
                file_group = self._dump_conflicts(
1309
 
                    name, (base_path, other_path, this_path), parent_id,
1310
 
                    file_id, set_version=True)
 
1309
                    name, (base_path, other_path, this_path), parent_id)
 
1310
                for tid in file_group:
 
1311
                    self.tt.version_file(tid, file_id=file_id)
 
1312
                    break
1311
1313
                self._raw_conflicts.append(('contents conflict', file_group))
1312
1314
        elif hook_status == 'success':
1313
1315
            self.tt.create_file(lines, trans_id)
1319
1321
            name = self.tt.final_name(trans_id)
1320
1322
            parent_id = self.tt.final_parent(trans_id)
1321
1323
            self._dump_conflicts(
1322
 
                name, (base_path, other_path, this_path), parent_id, file_id)
 
1324
                name, (base_path, other_path, this_path), parent_id)
1323
1325
        elif hook_status == 'delete':
1324
1326
            self.tt.unversion_file(trans_id)
1325
1327
            result = "deleted"
1425
1427
            self._raw_conflicts.append(('text conflict', trans_id))
1426
1428
            name = self.tt.final_name(trans_id)
1427
1429
            parent_id = self.tt.final_parent(trans_id)
1428
 
            file_id = self.tt.final_file_id(trans_id)
1429
 
            file_group = self._dump_conflicts(name, paths, parent_id, file_id,
1430
 
                                              this_lines, base_lines,
1431
 
                                              other_lines)
 
1430
            file_group = self._dump_conflicts(
 
1431
                name, paths, parent_id,
 
1432
                lines=(base_lines, other_lines, this_lines))
1432
1433
            file_group.append(trans_id)
1433
1434
 
1434
1435
    def _get_filter_tree_path(self, path):
1445
1446
        # Skip the lookup for older formats
1446
1447
        return None
1447
1448
 
1448
 
    def _dump_conflicts(self, name, paths, parent_id, file_id, this_lines=None,
1449
 
                        base_lines=None, other_lines=None, set_version=False,
 
1449
    def _dump_conflicts(self, name, paths, parent_id, lines=None,
1450
1450
                        no_base=False):
1451
1451
        """Emit conflict files.
1452
1452
        If this_lines, base_lines, or other_lines are omitted, they will be
1454
1454
        or .BASE (in that order) will be created as versioned files.
1455
1455
        """
1456
1456
        base_path, other_path, this_path = paths
 
1457
        if lines:
 
1458
            base_lines, other_lines, this_lines = lines
 
1459
        else:
 
1460
            base_lines = other_lines = this_lines = None
1457
1461
        data = [('OTHER', self.other_tree, other_path, other_lines),
1458
1462
                ('THIS', self.this_tree, this_path, this_lines)]
1459
1463
        if not no_base:
1466
1470
            # Skip the id2path lookup for older formats
1467
1471
            filter_tree_path = None
1468
1472
 
1469
 
        versioned = False
1470
1473
        file_group = []
1471
1474
        for suffix, tree, path, lines in data:
1472
1475
            if path is not None:
1474
1477
                    name, parent_id, path, tree, suffix, lines,
1475
1478
                    filter_tree_path)
1476
1479
                file_group.append(trans_id)
1477
 
                if set_version and not versioned:
1478
 
                    self.tt.version_file(trans_id, file_id=file_id)
1479
 
                    versioned = True
1480
1480
        return file_group
1481
1481
 
1482
1482
    def _conflict_file(self, name, parent_id, path, tree, suffix,
1646
1646
            self._raw_conflicts.append(('text conflict', trans_id))
1647
1647
            name = self.tt.final_name(trans_id)
1648
1648
            parent_id = self.tt.final_parent(trans_id)
1649
 
            file_id = self.tt.final_file_id(trans_id)
1650
 
            file_group = self._dump_conflicts(name, paths, parent_id, file_id,
1651
 
                                              no_base=False,
1652
 
                                              base_lines=base_lines)
 
1649
            file_group = self._dump_conflicts(name, paths, parent_id,
 
1650
                                              (base_lines, None, None),
 
1651
                                              no_base=False)
1653
1652
            file_group.append(trans_id)
1654
1653
 
1655
1654
 
1699
1698
            if status == 1:
1700
1699
                name = self.tt.final_name(trans_id)
1701
1700
                parent_id = self.tt.final_parent(trans_id)
1702
 
                file_id = self.tt.final_file_id(trans_id)
1703
 
                self._dump_conflicts(name, paths, parent_id, file_id)
 
1701
                self._dump_conflicts(name, paths, parent_id)
1704
1702
                self._raw_conflicts.append(('text conflict', trans_id))
1705
1703
        finally:
1706
1704
            osutils.rmtree(temp_dir)