/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/transform.py

  • Committer: Aaron Bentley
  • Date: 2006-01-25 16:01:44 UTC
  • mto: (1534.7.113 bzr.ttransform)
  • mto: This revision was merged to the branch mainline in revision 1558.
  • Revision ID: abentley@panoramicfeedback.com-20060125160144-d842bd38b846d915
Implemented weave merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1168
1168
            file_group.append(trans_id)
1169
1169
 
1170
1170
    def _dump_conflicts(self, name, parent_id, file_id, this_lines=None, 
1171
 
                        base_lines=None, other_lines=None, set_version=False):
1172
 
        data = (('OTHER', self.other_tree, other_lines), 
1173
 
                ('THIS', self.this_tree, this_lines),
1174
 
                ('BASE', self.base_tree, base_lines))
 
1171
                        base_lines=None, other_lines=None, set_version=False,
 
1172
                        no_base=False):
 
1173
        data = [('OTHER', self.other_tree, other_lines), 
 
1174
                ('THIS', self.this_tree, this_lines)]
 
1175
        if not no_base:
 
1176
            data.append(('BASE', self.base_tree, base_lines))
1175
1177
        versioned = False
1176
1178
        file_group = []
1177
1179
        for suffix, tree, lines in data:
1223
1225
                if executability is not None:
1224
1226
                    trans_id = self.tt.get_trans_id(file_id)
1225
1227
                    self.tt.set_executability(executability, trans_id)
 
1228
 
 
1229
class WeaveMerger(Merge3Merger):
 
1230
    supports_reprocess = False
 
1231
    supports_show_base = False
 
1232
    def _merged_lines(self, file_id):
 
1233
        """Generate the merged lines.
 
1234
        There is no distinction between lines that are meant to contain <<<<<<<
 
1235
        and conflicts.
 
1236
        """
 
1237
        if getattr(self.this_tree, 'get_weave', False) is False:
 
1238
            # If we have a WorkingTree, try using the basis
 
1239
            wt_sha1 = self.this_tree.get_file_sha1(file_id)
 
1240
            this_tree = self.this_tree.branch.basis_tree()
 
1241
            if this_tree.get_file_sha1(file_id) != wt_sha1:
 
1242
                raise WorkingTreeNotRevision(self.this_tree)
 
1243
        else:
 
1244
            this_tree = self.this_tree
 
1245
        weave = this_tree.get_weave(file_id)
 
1246
        this_revision_id = this_tree.inventory[file_id].revision
 
1247
        other_revision_id = self.other_tree.inventory[file_id].revision
 
1248
        this_i = weave.lookup(this_revision_id)
 
1249
        other_i = weave.lookup(other_revision_id)
 
1250
        plan =  weave.plan_merge(this_i, other_i)
 
1251
        return weave.weave_merge(plan)
 
1252
 
 
1253
    def text_merge(self, file_id, trans_id):
 
1254
        lines = self._merged_lines(file_id)
 
1255
        conflicts = '<<<<<<<\n' in lines
 
1256
        self.tt.create_file(lines, trans_id)
 
1257
        if conflicts:
 
1258
            self.conflicts.append(('text conflict', (file_id)))
 
1259
            name = self.tt.final_name(trans_id)
 
1260
            parent_id = self.tt.final_parent(trans_id)
 
1261
            file_group = self._dump_conflicts(name, parent_id, file_id, 
 
1262
                                              no_base=True)
 
1263
            file_group.append(trans_id)