536
536
self.add_version(('root', 'B'), [], 'xyz')
537
537
my_plan = _PlanMerge('A', 'B', self.plan_merge_vf, ('root',))
538
538
self.assertEqual([
539
542
('new-b', 'x\n'),
540
543
('new-b', 'y\n'),
545
545
list(my_plan.plan_merge()))
547
547
def test_plan_merge_uncommitted_files(self):
552
552
('unchanged', 'a\n'),
553
553
('killed-a', 'b\n'),
554
554
('killed-b', 'c\n'),
556
555
('new-a', 'e\n'),
557
556
('new-a', 'h\n'),
561
def test_plan_merge_insert_order(self):
562
"""Weave merges are sensitive to the order of insertion.
564
Specifically for overlapping regions, it effects which region gets put
565
'first'. And when a user resolves an overlapping merge, if they use the
566
same ordering, then the lines match the parents, if they don't only
567
*some* of the lines match.
569
self.add_version(('root', 'A'), [], 'abcdef')
570
self.add_version(('root', 'B'), [('root', 'A')], 'abwxcdef')
571
self.add_version(('root', 'C'), [('root', 'A')], 'abyzcdef')
572
# Merge, and resolve the conflict by adding *both* sets of lines
573
# If we get the ordering wrong, these will look like new lines in D,
574
# rather than carried over from B, C
575
self.add_version(('root', 'D'), [('root', 'B'), ('root', 'C')],
577
# Supersede the lines in B and delete the lines in C, which will
578
# conflict if they are treated as being in D
579
self.add_version(('root', 'E'), [('root', 'C'), ('root', 'B')],
581
# Same thing for the lines in C
582
self.add_version(('root', 'F'), [('root', 'C')], 'abpqcdef')
583
plan = self.plan_merge_vf.plan_merge('D', 'E')
585
('unchanged', 'a\n'),
586
('unchanged', 'b\n'),
593
('unchanged', 'c\n'),
594
('unchanged', 'd\n'),
595
('unchanged', 'e\n'),
596
('unchanged', 'f\n')],
598
plan = self.plan_merge_vf.plan_merge('E', 'D')
599
# Going in the opposite direction shows the effect of the opposite plan
601
('unchanged', 'a\n'),
602
('unchanged', 'b\n'),
607
('killed-both', 'w\n'),
608
('killed-both', 'x\n'),
611
('unchanged', 'c\n'),
612
('unchanged', 'd\n'),
613
('unchanged', 'e\n'),
614
('unchanged', 'f\n')],
561
617
def test_plan_merge_criss_cross(self):
562
618
# This is specificly trying to trigger problems when using limited
563
619
# ancestry and weaves. The ancestry graph looks like:
620
# XX unused ancestor, should not show up in the weave
566
624
# B \ Introduces a line 'foo'
581
639
# 'foo', it should appear as superseding the value in F (since it
582
640
# came from B), rather than conflict because of the resolution during
584
self.add_version(('root', 'A'), [], 'abcdef')
642
self.add_version(('root', 'XX'), [], 'qrs')
643
self.add_version(('root', 'A'), [('root', 'XX')], 'abcdef')
585
644
self.add_version(('root', 'B'), [('root', 'A')], 'axcdef')
586
645
self.add_version(('root', 'C'), [('root', 'B')], 'axcdefg')
587
646
self.add_version(('root', 'D'), [('root', 'B')], 'haxcdef')