81
81
def test_adds_with_parent_texts(self):
82
82
f = self.get_file()
84
parent_texts['r0'] = f.add_lines('r0', [], ['a\n', 'b\n'])
84
_, _, parent_texts['r0'] = f.add_lines('r0', [], ['a\n', 'b\n'])
86
parent_texts['r1'] = f.add_lines_with_ghosts('r1',
89
parent_texts=parent_texts)
86
_, _, parent_texts['r1'] = f.add_lines_with_ghosts('r1',
87
['r0', 'ghost'], ['b\n', 'c\n'], parent_texts=parent_texts)
90
88
except NotImplementedError:
91
89
# if the format doesn't support ghosts, just add normally.
92
parent_texts['r1'] = f.add_lines('r1',
95
parent_texts=parent_texts)
90
_, _, parent_texts['r1'] = f.add_lines('r1',
91
['r0'], ['b\n', 'c\n'], parent_texts=parent_texts)
96
92
f.add_lines('r2', ['r1'], ['c\n', 'd\n'], parent_texts=parent_texts)
97
93
self.assertNotEqual(None, parent_texts['r0'])
98
94
self.assertNotEqual(None, parent_texts['r1'])
168
164
self.assertRaises(errors.ReservedId,
169
165
vf.add_delta, 'a:', [], None, 'sha1', False, ((0, 0, 0, []),))
167
def test_add_lines_return_value(self):
168
# add_lines should return the sha1 and the text size.
170
empty_text = ('a', [])
171
sample_text_nl = ('b', ["foo\n", "bar\n"])
172
sample_text_no_nl = ('c', ["foo\n", "bar"])
173
# check results for the three cases:
174
for version, lines in (empty_text, sample_text_nl, sample_text_no_nl):
175
# the first two elements are the same for all versioned files:
176
# - the digest and the size of the text. For some versioned files
177
# additional data is returned in additional tuple elements.
178
result = vf.add_lines(version, [], lines)
179
self.assertEqual(3, len(result))
180
self.assertEqual((osutils.sha_strings(lines), sum(map(len, lines))),
182
# parents should not affect the result:
183
lines = sample_text_nl[1]
184
self.assertEqual((osutils.sha_strings(lines), sum(map(len, lines))),
185
vf.add_lines('d', ['b', 'c'], lines)[0:2])
171
187
def test_get_reserved(self):
172
188
vf = self.get_file()
173
189
self.assertRaises(errors.ReservedId, vf.get_delta, 'b:')