~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Ian Clatworthy
  • Date: 2010-03-30 20:13:52 UTC
  • mto: This revision was merged to the branch mainline in revision 5125.
  • Revision ID: ian.clatworthy@canonical.com-20100330201352-vw2gtujybyg3rvwc
whitespace fix in win32 installer

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
        """
131
131
        affected_files = self.affected_files
132
132
        if affected_files is None:
133
 
            config = self.merger.this_tree.branch.get_config()
 
133
            config = self.merger.this_branch.get_config()
134
134
            # Until bzr provides a better policy for caching the config, we
135
135
            # just add the part we're interested in to the params to avoid
136
136
            # reading the config files repeatedly (bazaar.conf, location.conf,
1173
1173
        return 'conflict'
1174
1174
 
1175
1175
    @staticmethod
 
1176
    @deprecated_method(deprecated_in((2, 2, 0)))
1176
1177
    def scalar_three_way(this_tree, base_tree, other_tree, file_id, key):
1177
1178
        """Do a three-way test on a scalar.
1178
1179
        Return "this", "other" or "conflict", depending whether a value wins.
1228
1229
                parent_id_winner = "other"
1229
1230
        if name_winner == "this" and parent_id_winner == "this":
1230
1231
            return
1231
 
        if name_winner == "conflict":
1232
 
            trans_id = self.tt.trans_id_file_id(file_id)
1233
 
            self._raw_conflicts.append(('name conflict', trans_id,
1234
 
                                        this_name, other_name))
1235
 
        if parent_id_winner == "conflict":
1236
 
            trans_id = self.tt.trans_id_file_id(file_id)
1237
 
            self._raw_conflicts.append(('parent conflict', trans_id,
1238
 
                                        this_parent, other_parent))
 
1232
        if name_winner == 'conflict' or parent_id_winner == 'conflict':
 
1233
            # Creating helpers (.OTHER or .THIS) here cause problems down the
 
1234
            # road if a ContentConflict needs to be created so we should not do
 
1235
            # that
 
1236
            trans_id = self.tt.trans_id_file_id(file_id)
 
1237
            self._raw_conflicts.append(('path conflict', trans_id, file_id,
 
1238
                                        this_parent, this_name,
 
1239
                                        other_parent, other_name))
1239
1240
        if other_name is None:
1240
1241
            # it doesn't matter whether the result was 'other' or
1241
1242
            # 'conflict'-- if there's no 'other', we leave it alone.
1242
1243
            return
1243
 
        # if we get here, name_winner and parent_winner are set to safe values.
1244
 
        trans_id = self.tt.trans_id_file_id(file_id)
1245
1244
        parent_id = parents[self.winner_idx[parent_id_winner]]
1246
1245
        if parent_id is not None:
1247
 
            parent_trans_id = self.tt.trans_id_file_id(parent_id)
 
1246
            # if we get here, name_winner and parent_winner are set to safe
 
1247
            # values.
1248
1248
            self.tt.adjust_path(names[self.winner_idx[name_winner]],
1249
 
                                parent_trans_id, trans_id)
 
1249
                                self.tt.trans_id_file_id(parent_id),
 
1250
                                self.tt.trans_id_file_id(file_id))
1250
1251
 
1251
1252
    def _do_merge_contents(self, file_id):
1252
1253
        """Performs a merge on file_id contents."""
1531
1532
 
1532
1533
    def cook_conflicts(self, fs_conflicts):
1533
1534
        """Convert all conflicts into a form that doesn't depend on trans_id"""
1534
 
        name_conflicts = {}
1535
1535
        self.cooked_conflicts.extend(transform.cook_conflicts(
1536
1536
                fs_conflicts, self.tt))
1537
1537
        fp = transform.FinalPaths(self.tt)
1538
1538
        for conflict in self._raw_conflicts:
1539
1539
            conflict_type = conflict[0]
1540
 
            if conflict_type in ('name conflict', 'parent conflict'):
1541
 
                trans_id = conflict[1]
1542
 
                conflict_args = conflict[2:]
1543
 
                if trans_id not in name_conflicts:
1544
 
                    name_conflicts[trans_id] = {}
1545
 
                transform.unique_add(name_conflicts[trans_id], conflict_type,
1546
 
                                     conflict_args)
1547
 
            if conflict_type == 'contents conflict':
 
1540
            if conflict_type == 'path conflict':
 
1541
                (trans_id, file_id,
 
1542
                this_parent, this_name,
 
1543
                other_parent, other_name) = conflict[1:]
 
1544
                if this_parent is None or this_name is None:
 
1545
                    this_path = '<deleted>'
 
1546
                else:
 
1547
                    parent_path =  fp.get_path(
 
1548
                        self.tt.trans_id_file_id(this_parent))
 
1549
                    this_path = osutils.pathjoin(parent_path, this_name)
 
1550
                if other_parent is None or other_name is None:
 
1551
                    other_path = '<deleted>'
 
1552
                else:
 
1553
                    parent_path =  fp.get_path(
 
1554
                        self.tt.trans_id_file_id(other_parent))
 
1555
                    other_path = osutils.pathjoin(parent_path, other_name)
 
1556
                c = _mod_conflicts.Conflict.factory(
 
1557
                    'path conflict', path=this_path,
 
1558
                    conflict_path=other_path,
 
1559
                    file_id=file_id)
 
1560
            elif conflict_type == 'contents conflict':
1548
1561
                for trans_id in conflict[1]:
1549
1562
                    file_id = self.tt.final_file_id(trans_id)
1550
1563
                    if file_id is not None:
1556
1569
                        break
1557
1570
                c = _mod_conflicts.Conflict.factory(conflict_type,
1558
1571
                                                    path=path, file_id=file_id)
1559
 
                self.cooked_conflicts.append(c)
1560
 
            if conflict_type == 'text conflict':
 
1572
            elif conflict_type == 'text conflict':
1561
1573
                trans_id = conflict[1]
1562
1574
                path = fp.get_path(trans_id)
1563
1575
                file_id = self.tt.final_file_id(trans_id)
1564
1576
                c = _mod_conflicts.Conflict.factory(conflict_type,
1565
1577
                                                    path=path, file_id=file_id)
1566
 
                self.cooked_conflicts.append(c)
1567
 
 
1568
 
        for trans_id, conflicts in name_conflicts.iteritems():
1569
 
            try:
1570
 
                this_parent, other_parent = conflicts['parent conflict']
1571
 
                if this_parent == other_parent:
1572
 
                    raise AssertionError()
1573
 
            except KeyError:
1574
 
                this_parent = other_parent = \
1575
 
                    self.tt.final_file_id(self.tt.final_parent(trans_id))
1576
 
            try:
1577
 
                this_name, other_name = conflicts['name conflict']
1578
 
                if this_name == other_name:
1579
 
                    raise AssertionError()
1580
 
            except KeyError:
1581
 
                this_name = other_name = self.tt.final_name(trans_id)
1582
 
            other_path = fp.get_path(trans_id)
1583
 
            if this_parent is not None and this_name is not None:
1584
 
                this_parent_path = \
1585
 
                    fp.get_path(self.tt.trans_id_file_id(this_parent))
1586
 
                this_path = osutils.pathjoin(this_parent_path, this_name)
1587
1578
            else:
1588
 
                this_path = "<deleted>"
1589
 
            file_id = self.tt.final_file_id(trans_id)
1590
 
            c = _mod_conflicts.Conflict.factory('path conflict', path=this_path,
1591
 
                                                conflict_path=other_path,
1592
 
                                                file_id=file_id)
 
1579
                raise AssertionError('bad conflict type: %r' % (conflict,))
1593
1580
            self.cooked_conflicts.append(c)
1594
1581
        self.cooked_conflicts.sort(key=_mod_conflicts.Conflict.sort_key)
1595
1582