791
791
['aaa', 'ddd', 'ccc'],
793
793
['<<<<', 'aaa', '====', '>>>>', 'ccc'])
796
class JoinWeavesTests(TestBase):
798
super(JoinWeavesTests, self).setUp()
799
self.weave1 = Weave()
800
self.lines1 = ['hello\n']
801
self.lines3 = ['hello\n', 'cruel\n', 'world\n']
802
self.weave1.add('v1', [], self.lines1)
803
self.weave1.add('v2', [0], ['hello\n', 'world\n'])
804
self.weave1.add('v3', [1], self.lines3)
806
def test_join_empty(self):
807
"""Join two empty weaves."""
808
eq = self.assertEqual
812
eq(w1.numversions(), 0)
814
def test_join_empty_to_nonempty(self):
815
"""Join empty weave onto nonempty."""
816
self.weave1.join(Weave())
817
self.assertEqual(len(self.weave1), 3)
819
def test_join_unrelated(self):
820
"""Join two weaves with no history in common."""
822
wb.add('b1', [], ['line from b\n'])
825
eq = self.assertEqual
827
eq(sorted(list(w1.iter_names())),
828
['b1', 'v1', 'v2', 'v3'])
830
def test_join_related(self):
831
wa = self.weave1.copy()
832
wb = self.weave1.copy()
833
wa.add('a1', ['v3'], ['hello\n', 'sweet\n', 'world\n'])
834
wb.add('b1', ['v3'], ['hello\n', 'pale blue\n', 'world\n'])
835
eq = self.assertEquals
840
eq(wa.get_lines('b1'),
841
['hello\n', 'pale blue\n', 'world\n'])
797
844
if __name__ == '__main__':