140
141
except NotImplementedError:
144
def test_add_reserved(self):
146
self.assertRaises(errors.ReservedId,
147
vf.add_lines, 'a:', [], ['a\n', 'b\n', 'c\n'])
149
self.assertRaises(errors.ReservedId,
150
vf.add_delta, 'a:', [], None, 'sha1', False, ((0, 0, 0, []),))
152
def test_get_reserved(self):
154
self.assertRaises(errors.ReservedId, vf.get_delta, 'b:')
155
self.assertRaises(errors.ReservedId, vf.get_texts, ['b:'])
156
self.assertRaises(errors.ReservedId, vf.get_lines, 'b:')
157
self.assertRaises(errors.ReservedId, vf.get_text, 'b:')
143
159
def test_get_delta(self):
144
160
f = self.get_file()
145
161
sha1s = self._setup_for_deltas(f)
198
214
self.assertEqual(expected_delta, deltas['noeol'])
199
215
# smoke tests for eol support - two noeol in a row same content
200
216
expected_deltas = (('noeol', '3ad7ee82dbd8f29ecba073f96e43e414b3f70a4d', True,
201
[(0, 1, 2, [(u'noeolsecond', 'line\n'), (u'noeolsecond', 'line\n')])]),
217
[(0, 1, 2, [('noeolsecond', 'line\n'), ('noeolsecond', 'line\n')])]),
202
218
('noeol', '3ad7ee82dbd8f29ecba073f96e43e414b3f70a4d', True,
203
219
[(0, 0, 1, [('noeolsecond', 'line\n')]), (1, 1, 0, [])]))
204
220
self.assertEqual(['line\n', 'line'], f.get_lines('noeolsecond'))
205
221
self.assertTrue(deltas['noeolsecond'] in expected_deltas)
206
222
# two no-eol in a row, different content
207
223
expected_delta = ('noeolsecond', '8bb553a84e019ef1149db082d65f3133b195223b', True,
208
[(1, 2, 1, [(u'noeolnotshared', 'phone\n')])])
224
[(1, 2, 1, [('noeolnotshared', 'phone\n')])])
209
225
self.assertEqual(['line\n', 'phone'], f.get_lines('noeolnotshared'))
210
226
self.assertEqual(expected_delta, deltas['noeolnotshared'])
211
227
# eol folling a no-eol with content change
212
228
expected_delta = ('noeol', 'a61f6fb6cfc4596e8d88c34a308d1e724caf8977', False,
213
[(0, 1, 1, [(u'eol', 'phone\n')])])
229
[(0, 1, 1, [('eol', 'phone\n')])])
214
230
self.assertEqual(['phone\n'], f.get_lines('eol'))
215
231
self.assertEqual(expected_delta, deltas['eol'])
216
232
# eol folling a no-eol with content change
217
233
expected_delta = ('noeol', '6bfa09d82ce3e898ad4641ae13dd4fdb9cf0d76b', False,
218
[(0, 1, 1, [(u'eolline', 'line\n')])])
234
[(0, 1, 1, [('eolline', 'line\n')])])
219
235
self.assertEqual(['line\n'], f.get_lines('eolline'))
220
236
self.assertEqual(expected_delta, deltas['eolline'])
221
237
# eol with no parents
222
238
expected_delta = (None, '264f39cab871e4cfd65b3a002f7255888bb5ed97', True,
223
[(0, 0, 1, [(u'noeolbase', 'line\n')])])
239
[(0, 0, 1, [('noeolbase', 'line\n')])])
224
240
self.assertEqual(['line'], f.get_lines('noeolbase'))
225
241
self.assertEqual(expected_delta, deltas['noeolbase'])
226
242
# eol with two parents, in inverse insertion order
227
243
expected_deltas = (('noeolbase', '264f39cab871e4cfd65b3a002f7255888bb5ed97', True,
228
[(0, 1, 1, [(u'eolbeforefirstparent', 'line\n')])]),
244
[(0, 1, 1, [('eolbeforefirstparent', 'line\n')])]),
229
245
('noeolbase', '264f39cab871e4cfd65b3a002f7255888bb5ed97', True,
230
[(0, 1, 1, [(u'eolbeforefirstparent', 'line\n')])]))
246
[(0, 1, 1, [('eolbeforefirstparent', 'line\n')])]))
231
247
self.assertEqual(['line'], f.get_lines('eolbeforefirstparent'))
232
248
#self.assertTrue(deltas['eolbeforefirstparent'] in expected_deltas)
666
685
# test key graph related apis: getncestry, _graph, get_parents
668
687
# - these are ghost unaware and must not be reflect ghosts
669
self.assertEqual([u'notbxbfse'], vf.get_ancestry(u'notbxbfse'))
670
self.assertEqual([], vf.get_parents(u'notbxbfse'))
671
self.assertEqual({u'notbxbfse':[]}, vf.get_graph())
672
self.assertFalse(vf.has_version(u'b\xbfse'))
688
self.assertEqual(['notbxbfse'], vf.get_ancestry('notbxbfse'))
689
self.assertEqual([], vf.get_parents('notbxbfse'))
690
self.assertEqual({'notbxbfse':[]}, vf.get_graph())
691
self.assertFalse(self.callDeprecated([osutils._revision_id_warning],
692
vf.has_version, parent_id_unicode))
693
self.assertFalse(vf.has_version(parent_id_utf8))
673
694
# we have _with_ghost apis to give us ghost information.
674
self.assertEqual([u'b\xbfse', u'notbxbfse'], vf.get_ancestry_with_ghosts([u'notbxbfse']))
675
self.assertEqual([u'b\xbfse'], vf.get_parents_with_ghosts(u'notbxbfse'))
676
self.assertEqual({u'notbxbfse':[u'b\xbfse']}, vf.get_graph_with_ghosts())
677
self.assertTrue(vf.has_ghost(u'b\xbfse'))
695
self.assertEqual([parent_id_utf8, 'notbxbfse'], vf.get_ancestry_with_ghosts(['notbxbfse']))
696
self.assertEqual([parent_id_utf8], vf.get_parents_with_ghosts('notbxbfse'))
697
self.assertEqual({'notbxbfse':[parent_id_utf8]}, vf.get_graph_with_ghosts())
698
self.assertTrue(self.callDeprecated([osutils._revision_id_warning],
699
vf.has_ghost, parent_id_unicode))
700
self.assertTrue(vf.has_ghost(parent_id_utf8))
678
701
# if we add something that is a ghost of another, it should correct the
679
702
# results of the prior apis
680
vf.add_lines(u'b\xbfse', [], [])
681
self.assertEqual([u'b\xbfse', u'notbxbfse'], vf.get_ancestry([u'notbxbfse']))
682
self.assertEqual([u'b\xbfse'], vf.get_parents(u'notbxbfse'))
683
self.assertEqual({u'b\xbfse':[],
684
u'notbxbfse':[u'b\xbfse'],
703
self.callDeprecated([osutils._revision_id_warning],
704
vf.add_lines, parent_id_unicode, [], [])
705
self.assertEqual([parent_id_utf8, 'notbxbfse'], vf.get_ancestry(['notbxbfse']))
706
self.assertEqual([parent_id_utf8], vf.get_parents('notbxbfse'))
707
self.assertEqual({parent_id_utf8:[],
708
'notbxbfse':[parent_id_utf8],
687
self.assertTrue(vf.has_version(u'b\xbfse'))
711
self.assertTrue(self.callDeprecated([osutils._revision_id_warning],
712
vf.has_version, parent_id_unicode))
713
self.assertTrue(vf.has_version(parent_id_utf8))
688
714
# we have _with_ghost apis to give us ghost information.
689
self.assertEqual([u'b\xbfse', u'notbxbfse'], vf.get_ancestry_with_ghosts([u'notbxbfse']))
690
self.assertEqual([u'b\xbfse'], vf.get_parents_with_ghosts(u'notbxbfse'))
691
self.assertEqual({u'b\xbfse':[],
692
u'notbxbfse':[u'b\xbfse'],
715
self.assertEqual([parent_id_utf8, 'notbxbfse'], vf.get_ancestry_with_ghosts(['notbxbfse']))
716
self.assertEqual([parent_id_utf8], vf.get_parents_with_ghosts('notbxbfse'))
717
self.assertEqual({parent_id_utf8:[],
718
'notbxbfse':[parent_id_utf8],
694
720
vf.get_graph_with_ghosts())
695
self.assertFalse(vf.has_ghost(u'b\xbfse'))
721
self.assertFalse(self.callDeprecated([osutils._revision_id_warning],
722
vf.has_ghost, parent_id_unicode))
723
self.assertFalse(vf.has_ghost(parent_id_utf8))
697
725
def test_add_lines_with_ghosts_after_normal_revs(self):
698
726
# some versioned file formats allow lines to be added with parent