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