797
797
return self._factory
800
class TestPlanMergeVersionedFile(TestCaseWithMemoryTransport):
803
TestCaseWithMemoryTransport.setUp(self)
804
self.vf1 = KnitVersionedFile('root', self.get_transport(), create=True)
805
self.vf2 = KnitVersionedFile('root', self.get_transport(), create=True)
806
self.plan_merge_vf = versionedfile._PlanMergeVersionedFile('root',
807
[self.vf1, self.vf2])
809
def test_add_lines(self):
810
self.plan_merge_vf.add_lines('a:', [], [])
811
self.assertRaises(ValueError, self.plan_merge_vf.add_lines, 'a', [],
813
self.assertRaises(ValueError, self.plan_merge_vf.add_lines, 'a:', None,
815
self.assertRaises(ValueError, self.plan_merge_vf.add_lines, 'a:', [],
818
def test_ancestry(self):
819
self.vf1.add_lines('A', [], [])
820
self.vf1.add_lines('B', ['A'], [])
821
self.plan_merge_vf.add_lines('C:', ['B'], [])
822
self.plan_merge_vf.add_lines('D:', ['C:'], [])
823
self.assertEqual(set(['A', 'B', 'C:', 'D:']),
824
self.plan_merge_vf.get_ancestry('D:', topo_sorted=False))
826
def setup_abcde(self):
827
self.vf1.add_lines('A', [], ['a'])
828
self.vf1.add_lines('B', ['A'], ['b'])
829
self.vf2.add_lines('C', [], ['c'])
830
self.vf2.add_lines('D', ['C'], ['d'])
831
self.plan_merge_vf.add_lines('E:', ['B', 'D'], ['e'])
833
def test_ancestry_uses_all_versionedfiles(self):
835
self.assertEqual(set(['A', 'B', 'C', 'D', 'E:']),
836
self.plan_merge_vf.get_ancestry('E:', topo_sorted=False))
838
def test_ancestry_raises_revision_not_present(self):
839
error = self.assertRaises(errors.RevisionNotPresent,
840
self.plan_merge_vf.get_ancestry, 'E:', False)
841
self.assertContainsRe(str(error), '{E:} not present in "root"')
843
def test_get_parents(self):
845
self.assertEqual(['A'], self.plan_merge_vf.get_parents('B'))
846
self.assertEqual(['C'], self.plan_merge_vf.get_parents('D'))
847
self.assertEqual(['B', 'D'], self.plan_merge_vf.get_parents('E:'))
848
error = self.assertRaises(errors.RevisionNotPresent,
849
self.plan_merge_vf.get_parents, 'F')
850
self.assertContainsRe(str(error), '{F} not present in "root"')
852
def test_get_lines(self):
854
self.assertEqual(['a'], self.plan_merge_vf.get_lines('A'))
855
self.assertEqual(['c'], self.plan_merge_vf.get_lines('C'))
856
self.assertEqual(['e'], self.plan_merge_vf.get_lines('E:'))
857
error = self.assertRaises(errors.RevisionNotPresent,
858
self.plan_merge_vf.get_lines, 'F')
859
self.assertContainsRe(str(error), '{F} not present in "root"')
800
862
class InterString(versionedfile.InterVersionedFile):
801
863
"""An inter-versionedfile optimised code path for strings.