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

  • Committer: Andrew Bennetts
  • Date: 2009-12-18 08:22:42 UTC
  • mfrom: (4906 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4909.
  • Revision ID: andrew.bennetts@canonical.com-20091218082242-f7wy9tlk0yxvkkju
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1406
1406
    supports_reverse_cherrypick = False
1407
1407
    history_based = True
1408
1408
 
 
1409
    def _generate_merge_plan(self, file_id, base):
 
1410
        return self.this_tree.plan_file_merge(file_id, self.other_tree,
 
1411
                                              base=base)
 
1412
 
1409
1413
    def _merged_lines(self, file_id):
1410
1414
        """Generate the merged lines.
1411
1415
        There is no distinction between lines that are meant to contain <<<<<<<
1415
1419
            base = self.base_tree
1416
1420
        else:
1417
1421
            base = None
1418
 
        plan = self._plan_file_merge(file_id, base)
 
1422
        plan = self._generate_merge_plan(file_id, base)
1419
1423
        if 'merge' in debug.debug_flags:
1420
1424
            plan = list(plan)
1421
1425
            trans_id = self.tt.trans_id_file_id(file_id)
1422
1426
            name = self.tt.final_name(trans_id) + '.plan'
1423
 
            contents = ('%10s|%s' % l for l in plan)
 
1427
            contents = ('%11s|%s' % l for l in plan)
1424
1428
            self.tt.new_file(name, self.tt.final_parent(trans_id), contents)
1425
1429
        textmerge = versionedfile.PlanWeaveMerge(plan, '<<<<<<< TREE\n',
1426
1430
                                                 '>>>>>>> MERGE-SOURCE\n')
1427
 
        return textmerge.merge_lines(self.reprocess)
1428
 
 
1429
 
    def _plan_file_merge(self, file_id, base):
1430
 
        return self.this_tree.plan_file_merge(
1431
 
            file_id, self.other_tree, base=base)
 
1431
        lines, conflicts = textmerge.merge_lines(self.reprocess)
 
1432
        if conflicts:
 
1433
            base_lines = textmerge.base_from_plan()
 
1434
        else:
 
1435
            base_lines = None
 
1436
        return lines, base_lines
1432
1437
 
1433
1438
    def text_merge(self, file_id, trans_id):
1434
1439
        """Perform a (weave) text merge for a given file and file-id.
1435
1440
        If conflicts are encountered, .THIS and .OTHER files will be emitted,
1436
1441
        and a conflict will be noted.
1437
1442
        """
1438
 
        lines, conflicts = self._merged_lines(file_id)
 
1443
        lines, base_lines = self._merged_lines(file_id)
1439
1444
        lines = list(lines)
1440
1445
        # Note we're checking whether the OUTPUT is binary in this case,
1441
1446
        # because we don't want to get into weave merge guts.
1442
1447
        textfile.check_text_lines(lines)
1443
1448
        self.tt.create_file(lines, trans_id)
1444
 
        if conflicts:
 
1449
        if base_lines is not None:
 
1450
            # Conflict
1445
1451
            self._raw_conflicts.append(('text conflict', trans_id))
1446
1452
            name = self.tt.final_name(trans_id)
1447
1453
            parent_id = self.tt.final_parent(trans_id)
1448
1454
            file_group = self._dump_conflicts(name, parent_id, file_id,
1449
 
                                              no_base=True)
 
1455
                                              no_base=False,
 
1456
                                              base_lines=base_lines)
1450
1457
            file_group.append(trans_id)
1451
1458
 
1452
1459
 
1453
1460
class LCAMerger(WeaveMerger):
1454
1461
 
1455
 
    def _plan_file_merge(self, file_id, base):
1456
 
        return self.this_tree.plan_file_lca_merge(
1457
 
            file_id, self.other_tree, base=base)
1458
 
 
 
1462
    def _generate_merge_plan(self, file_id, base):
 
1463
        return self.this_tree.plan_file_lca_merge(file_id, self.other_tree,
 
1464
                                                  base=base)
1459
1465
 
1460
1466
class Diff3Merger(Merge3Merger):
1461
1467
    """Three-way merger using external diff3 for text merging"""