154
154
text = text + ['line\n']
155
155
f.add_lines(new_version, [next_parent], text)
156
156
next_parent = new_version
157
expected_delta = (None, '6bfa09d82ce3e898ad4641ae13dd4fdb9cf0d76b', [(0, 0, 1, [('base', 'line\n')])])
157
f.add_lines('noeol', ['base'], ['line'])
158
expected_delta = (None, '6bfa09d82ce3e898ad4641ae13dd4fdb9cf0d76b', False,
159
[(0, 0, 1, [('base', 'line\n')])])
158
160
self.assertEqual(expected_delta, f.get_delta('base'))
159
161
next_parent = 'base'
160
162
next_name = 'chain1-'
161
163
for depth in range(26):
162
164
new_version = text_name + '%s' % depth
163
expected_delta = (next_parent, sha1s[depth], [(depth + 1, depth + 1, 1, [(new_version, 'line\n')])])
165
expected_delta = (next_parent, sha1s[depth],
167
[(depth + 1, depth + 1, 1, [(new_version, 'line\n')])])
164
168
self.assertEqual(expected_delta, f.get_delta(new_version))
165
169
next_parent = new_version
166
170
next_parent = 'base'
167
171
next_name = 'chain2-'
168
172
for depth in range(26):
169
173
new_version = text_name + '%s' % depth
170
expected_delta = (next_parent, sha1s[depth], [(depth + 1, depth + 1, 1, [(new_version, 'line\n')])])
174
expected_delta = (next_parent, sha1s[depth], False,
175
[(depth + 1, depth + 1, 1, [(new_version, 'line\n')])])
171
176
self.assertEqual(expected_delta, f.get_delta(new_version))
172
177
next_parent = new_version
178
# smoke test for eol support
179
expected_delta = ('base', '264f39cab871e4cfd65b3a002f7255888bb5ed97', True, [])
180
self.assertEqual(['line'], f.get_lines('noeol'))
181
self.assertEqual(expected_delta, f.get_delta('noeol'))
183
def test_add_delta(self):
184
# tests for the add-delta facility.
185
# at this point, optimising for speed, we assume no checks when deltas are inserted.
186
# this may need to be revisited.
187
source = self.get_file('source')
188
source.add_lines('base', [], ['line\n'])
190
text_name = 'chain1-'
192
for depth in range(26):
193
new_version = text_name + '%s' % depth
194
text = text + ['line\n']
195
source.add_lines(new_version, [next_parent], text)
196
next_parent = new_version
198
text_name = 'chain2-'
200
for depth in range(26):
201
new_version = text_name + '%s' % depth
202
text = text + ['line\n']
203
source.add_lines(new_version, [next_parent], text)
204
next_parent = new_version
205
source.add_lines('noeol', ['base'], ['line'])
207
target = self.get_file('target')
208
for version in source.versions():
209
parent, sha1, noeol, delta = source.get_delta(version)
210
target.add_delta(version,
211
source.get_parents(version),
216
self.assertRaises(RevisionAlreadyPresent,
217
target.add_delta, 'base', [], None, '', False, [])
218
for version in source.versions():
219
self.assertEqual(source.get_lines(version),
220
target.get_lines(version))
174
222
def test_ancestry(self):
175
223
f = self.get_file()
202
250
def test_mutate_after_finish(self):
203
251
f = self.get_file()
204
252
f.transaction_finished()
253
self.assertRaises(errors.OutSideTransaction, f.add_delta, '', [], '', '', False, [])
205
254
self.assertRaises(errors.OutSideTransaction, f.add_lines, '', [], [])
206
255
self.assertRaises(errors.OutSideTransaction, f.add_lines_with_ghosts, '', [], [])
207
256
self.assertRaises(errors.OutSideTransaction, f.fix_parents, '', [])
492
541
factory = self.get_factory()
493
542
vf = factory('id', transport, 0777, create=True, access_mode='w')
494
543
vf = factory('id', transport, access_mode='r')
544
self.assertRaises(errors.ReadOnlyError, vf.add_delta, '', [], '', '', False, [])
495
545
self.assertRaises(errors.ReadOnlyError, vf.add_lines, 'base', [], [])
496
546
self.assertRaises(errors.ReadOnlyError,
497
547
vf.add_lines_with_ghosts,