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