632
632
# Merge G & H but supersede an old line in B
633
633
self.add_rev('root', 'J', ['H', 'Q', 'G'], 'DaJbCcF')
634
634
plan = self.plan_merge_vf.plan_merge('I', 'J')
635
# This has a slight incorrect value, as it considers the lines in A to
636
# be 'killed-base', because they show up as new in both B and C, and
637
# then E has to resolve which ones are the 'real' ones.
638
# However, I believe this is okay as the important lines will all
640
635
self.assertEqual([
641
636
('unchanged', 'D\n'),
642
637
('unchanged', 'a\n'),
643
638
('killed-b', 'B\n'),
644
639
('new-b', 'J\n'),
645
640
('unchanged', 'b\n'),
646
('killed-base', 'c\n'), # Not technically correct
647
('killed-base', 'a\n'), # as they came from A
648
('killed-base', 'b\n'), # but the final text is right
649
641
('unchanged', 'C\n'),
650
642
('unchanged', 'c\n'),
651
643
('unchanged', 'F\n')],
813
805
{1: [3], 2: [3, 4], 3: [5], 4: []})
807
def assertPruneTails(self, pruned_map, tails, parent_map):
809
for key, parent_keys in parent_map.iteritems():
810
child_map.setdefault(key, [])
811
for pkey in parent_keys:
812
child_map.setdefault(pkey, []).append(key)
813
_PlanMerge._prune_tails(parent_map, child_map, tails)
814
self.assertEqual(pruned_map, parent_map)
816
def test__prune_tails(self):
817
# Nothing requested to prune
818
self.assertPruneTails({1: [], 2: [], 3: []}, [],
819
{1: [], 2: [], 3: []})
820
# Prune a single entry
821
self.assertPruneTails({1: [], 3: []}, [2],
822
{1: [], 2: [], 3: []})
824
self.assertPruneTails({1: []}, [3],
825
{1: [], 2: [3], 3: []})
826
# Prune a chain with a diamond
827
self.assertPruneTails({1: []}, [5],
828
{1: [], 2: [3, 4], 3: [5], 4: [5], 5: []})
829
# Prune a partial chain
830
self.assertPruneTails({1: [6], 6:[]}, [5],
831
{1: [2, 6], 2: [3, 4], 3: [5], 4: [5], 5: [],
833
# Prune a chain with multiple tips, that pulls out intermediates
834
self.assertPruneTails({1:[3], 3:[]}, [4, 5],
835
{1: [2, 3], 2: [4, 5], 3: [], 4:[], 5:[]})
836
self.assertPruneTails({1:[3], 3:[]}, [5, 4],
837
{1: [2, 3], 2: [4, 5], 3: [], 4:[], 5:[]})
815
839
def test_subtract_plans(self):
817
841
('unchanged', 'a\n'),