33
33
multiparent.ParentText(0, 3, 4, 1)],
36
def test_range_iterator(self):
37
diff = multiparent.MultiParent.from_lines(LINES_1, [LINES_2, LINES_3])
38
diff.hunks.append(multiparent.NewText(['q\n']))
39
self.assertEqual([(0, 4, 'parent', (1, 0, 4)),
40
(4, 5, 'parent', (0, 3, 4)),
41
(5, 6, 'new', ['q\n'])],
42
list(diff.range_iterator()))
37
45
diff = multiparent.MultiParent.from_lines(LINES_1)
38
46
diff2 = multiparent.MultiParent.from_lines(LINES_1)
86
94
list(multiparent.ParentText(0, 1, 2, 3).to_patch()))
97
REV_A = ['a\n', 'b\n', 'c\n', 'd\n']
98
REV_B = ['a\n', 'c\n', 'd\n', 'e\n']
99
REV_C = ['a\n', 'b\n', 'e\n', 'f\n']
89
102
class TestVersionedFile(TestCase):
91
104
def add_version(self, vf, text, version_id, parent_ids):
92
105
vf.add_version([(t+'\n') for t in text], version_id, parent_ids)
94
def test_add_version(self):
95
108
vf = multiparent.MultiVersionedFile()
96
109
self.add_version(vf, 'abcd', 'rev-a', [])
97
self.assertEqual(vf._lines['rev-a'], ['a\n', 'b\n', 'c\n', 'd\n'])
110
self.add_version(vf, 'acde', 'rev-b', [])
111
self.add_version(vf, 'abef', 'rev-c', ['rev-a', 'rev-b'])
114
def test_add_version(self):
116
self.assertEqual(REV_A, vf._lines['rev-a'])
99
118
self.assertEqual(vf._lines, {})
120
def test_get_line_list(self):
123
self.assertEqual(REV_A, vf.get_line_list(['rev-a'])[0])
124
self.assertEqual([REV_B, REV_C], vf.get_line_list(['rev-b', 'rev-c']))
127
def reconstruct(vf, revision_id, start, end):
128
reconstructor = multiparent._Reconstructor(vf._diffs, vf._lines,
131
reconstructor._reconstruct(lines, revision_id, start, end)
134
def test_reconstructor(self):
136
self.assertEqual(['a\n', 'b\n'], self.reconstruct(vf, 'rev-a', 0, 2))
137
self.assertEqual(['c\n', 'd\n'], self.reconstruct(vf, 'rev-a', 2, 4))
138
self.assertEqual(['e\n', 'f\n'], self.reconstruct(vf, 'rev-c', 2, 4))