500
500
plan._get_matching_blocks('B', 'C')),
501
501
([1, 2, 3], [0, 2]))
503
def test_find_new(self):
504
plan = self.setup_plan_merge()
505
self.assertEqual(set([2, 3, 4]), plan._find_new('B'))
506
self.assertEqual(set([0, 3]), plan._find_new('C'))
508
def test_find_new2(self):
503
def test_plan_merge_cherrypick(self):
509
504
self.add_version(('root', 'A'), [], 'abc')
510
505
self.add_version(('root', 'B'), [('root', 'A')], 'abcde')
511
506
self.add_version(('root', 'C'), [('root', 'A')], 'abcefg')
512
507
self.add_version(('root', 'D'),
513
508
[('root', 'A'), ('root', 'B'), ('root', 'C')], 'abcdegh')
514
509
my_plan = _PlanMerge('B', 'D', self.plan_merge_vf, ('root',))
515
self.assertEqual(set([5, 6]), my_plan._find_new('D'))
516
self.assertEqual(set(), my_plan._find_new('A'))
511
('unchanged', 'a\n'),
512
('unchanged', 'b\n'),
513
('unchanged', 'c\n'),
514
('unchanged', 'd\n'),
515
('unchanged', 'e\n'),
518
list(my_plan.plan_merge()))
518
def test_find_new_no_ancestors(self):
520
def test_plan_merge_no_common_ancestor(self):
519
521
self.add_version(('root', 'A'), [], 'abc')
520
522
self.add_version(('root', 'B'), [], 'xyz')
521
my_plan = _PlanMerge('A', 'B', self.vf, ('root',))
522
self.assertEqual(set([0, 1, 2]), my_plan._find_new('A'))
523
my_plan = _PlanMerge('A', 'B', self.plan_merge_vf, ('root',))
531
list(my_plan.plan_merge()))
524
533
def test_plan_merge(self):
525
534
self.setup_plan_merge()
662
673
self.add_version(('root', 'A'), [('root', 'C')], 'b')
663
674
self.add_version(('root', 'B'), [('root', 'C')], '')
664
675
plan = self.plan_merge_vf.plan_merge('A', 'B')
665
self.assertEqual([('new-a', 'b\n'),
666
('killed-both', 'a\n')
676
self.assertEqual([('killed-both', 'a\n'),
680
def test_plan_merge_with_move_and_change(self):
681
self.add_version(('root', 'C'), [], 'abcd')
682
self.add_version(('root', 'A'), [('root', 'C')], 'acbd')
683
self.add_version(('root', 'B'), [('root', 'C')], 'aBcd')
684
plan = self.plan_merge_vf.plan_merge('A', 'B')
685
self.assertEqual([('unchanged', 'a\n'),
690
('unchanged', 'd\n'),
703
727
self.assertFileEqual('d\na\nb\nc\n', 'this/file1')
704
728
self.assertFileEqual('d\na\nb\n', 'this/file2')
706
def test_merge_delete_and_change(self):
730
def test_merge_move_and_change(self):
707
731
this_tree = self.make_branch_and_tree('this')
708
732
this_tree.lock_write()
709
733
self.addCleanup(this_tree.unlock)
710
734
self.build_tree_contents([
711
('this/file1', 'a\nb\n'),
735
('this/file1', 'line 1\nline 2\nline 3\nline 4\n'),
713
737
this_tree.add('file1',)
714
738
this_tree.commit('Added file')
715
739
other_tree = this_tree.bzrdir.sprout('other').open_workingtree()
716
740
self.build_tree_contents([
717
('other/file1', 'a\nc\n'),
741
('other/file1', 'line 1\nline 2 to 2.1\nline 3\nline 4\n'),
719
other_tree.commit('Changed b to c')
743
other_tree.commit('Swapped 2 & 3')
720
744
self.build_tree_contents([
721
('this/file1', 'a\n'),
745
('this/file1', 'line 1\nline 3\nline 2\nline 4\n'),
723
this_tree.commit('Deleted b')
747
this_tree.commit('Changed 2 to 2.1')
724
748
self.do_merge(this_tree, other_tree)
725
self.assertFileEqual('a\n'
749
self.assertFileEqual('line 1\n'
729
'>>>>>>> MERGE-SOURCE\n', 'this/file1')
756
'>>>>>>> MERGE-SOURCE\n'
757
'line 4\n', 'this/file1')
732
760
class TestMerge3Merge(TestCaseWithTransport, TestMergeImplementation):
742
770
class TestLCAMerge(TestCaseWithTransport, TestMergeImplementation):
744
772
merge_type = _mod_merge.LCAMerger
774
def test_merge_move_and_change(self):
775
self.expectFailure("lca merge doesn't conflict for move and change",
776
super(TestLCAMerge, self).test_merge_move_and_change)