213
213
self.assertEqual(expected_delta, deltas['noeol'])
214
214
# smoke tests for eol support - two noeol in a row same content
215
215
expected_deltas = (('noeol', '3ad7ee82dbd8f29ecba073f96e43e414b3f70a4d', True,
216
[(0, 1, 2, [(u'noeolsecond', 'line\n'), (u'noeolsecond', 'line\n')])]),
216
[(0, 1, 2, [('noeolsecond', 'line\n'), ('noeolsecond', 'line\n')])]),
217
217
('noeol', '3ad7ee82dbd8f29ecba073f96e43e414b3f70a4d', True,
218
218
[(0, 0, 1, [('noeolsecond', 'line\n')]), (1, 1, 0, [])]))
219
219
self.assertEqual(['line\n', 'line'], f.get_lines('noeolsecond'))
220
220
self.assertTrue(deltas['noeolsecond'] in expected_deltas)
221
221
# two no-eol in a row, different content
222
222
expected_delta = ('noeolsecond', '8bb553a84e019ef1149db082d65f3133b195223b', True,
223
[(1, 2, 1, [(u'noeolnotshared', 'phone\n')])])
223
[(1, 2, 1, [('noeolnotshared', 'phone\n')])])
224
224
self.assertEqual(['line\n', 'phone'], f.get_lines('noeolnotshared'))
225
225
self.assertEqual(expected_delta, deltas['noeolnotshared'])
226
226
# eol folling a no-eol with content change
227
227
expected_delta = ('noeol', 'a61f6fb6cfc4596e8d88c34a308d1e724caf8977', False,
228
[(0, 1, 1, [(u'eol', 'phone\n')])])
228
[(0, 1, 1, [('eol', 'phone\n')])])
229
229
self.assertEqual(['phone\n'], f.get_lines('eol'))
230
230
self.assertEqual(expected_delta, deltas['eol'])
231
231
# eol folling a no-eol with content change
232
232
expected_delta = ('noeol', '6bfa09d82ce3e898ad4641ae13dd4fdb9cf0d76b', False,
233
[(0, 1, 1, [(u'eolline', 'line\n')])])
233
[(0, 1, 1, [('eolline', 'line\n')])])
234
234
self.assertEqual(['line\n'], f.get_lines('eolline'))
235
235
self.assertEqual(expected_delta, deltas['eolline'])
236
236
# eol with no parents
237
237
expected_delta = (None, '264f39cab871e4cfd65b3a002f7255888bb5ed97', True,
238
[(0, 0, 1, [(u'noeolbase', 'line\n')])])
238
[(0, 0, 1, [('noeolbase', 'line\n')])])
239
239
self.assertEqual(['line'], f.get_lines('noeolbase'))
240
240
self.assertEqual(expected_delta, deltas['noeolbase'])
241
241
# eol with two parents, in inverse insertion order
242
242
expected_deltas = (('noeolbase', '264f39cab871e4cfd65b3a002f7255888bb5ed97', True,
243
[(0, 1, 1, [(u'eolbeforefirstparent', 'line\n')])]),
243
[(0, 1, 1, [('eolbeforefirstparent', 'line\n')])]),
244
244
('noeolbase', '264f39cab871e4cfd65b3a002f7255888bb5ed97', True,
245
[(0, 1, 1, [(u'eolbeforefirstparent', 'line\n')])]))
245
[(0, 1, 1, [('eolbeforefirstparent', 'line\n')])]))
246
246
self.assertEqual(['line'], f.get_lines('eolbeforefirstparent'))
247
247
#self.assertTrue(deltas['eolbeforefirstparent'] in expected_deltas)
681
684
# test key graph related apis: getncestry, _graph, get_parents
683
686
# - these are ghost unaware and must not be reflect ghosts
684
self.assertEqual([u'notbxbfse'], vf.get_ancestry(u'notbxbfse'))
685
self.assertEqual([], vf.get_parents(u'notbxbfse'))
686
self.assertEqual({u'notbxbfse':[]}, vf.get_graph())
687
self.assertFalse(vf.has_version(u'b\xbfse'))
687
self.assertEqual(['notbxbfse'], vf.get_ancestry('notbxbfse'))
688
self.assertEqual([], vf.get_parents('notbxbfse'))
689
self.assertEqual({'notbxbfse':[]}, vf.get_graph())
690
self.assertFalse(vf.has_version(parent_id_unicode))
691
self.assertFalse(vf.has_version(parent_id_utf8))
688
692
# 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'notbxbfse':[u'b\xbfse']}, vf.get_graph_with_ghosts())
692
self.assertTrue(vf.has_ghost(u'b\xbfse'))
693
self.assertEqual([parent_id_utf8, 'notbxbfse'], vf.get_ancestry_with_ghosts(['notbxbfse']))
694
self.assertEqual([parent_id_utf8], vf.get_parents_with_ghosts('notbxbfse'))
695
self.assertEqual({'notbxbfse':[parent_id_utf8]}, vf.get_graph_with_ghosts())
696
self.assertTrue(vf.has_ghost(parent_id_unicode))
697
self.assertTrue(vf.has_ghost(parent_id_utf8))
693
698
# if we add something that is a ghost of another, it should correct the
694
699
# results of the prior apis
695
vf.add_lines(u'b\xbfse', [], [])
696
self.assertEqual([u'b\xbfse', u'notbxbfse'], vf.get_ancestry([u'notbxbfse']))
697
self.assertEqual([u'b\xbfse'], vf.get_parents(u'notbxbfse'))
698
self.assertEqual({u'b\xbfse':[],
699
u'notbxbfse':[u'b\xbfse'],
700
vf.add_lines(parent_id_unicode, [], [])
701
self.assertEqual([parent_id_utf8, 'notbxbfse'], vf.get_ancestry(['notbxbfse']))
702
self.assertEqual([parent_id_utf8], vf.get_parents('notbxbfse'))
703
self.assertEqual({parent_id_utf8:[],
704
'notbxbfse':[parent_id_utf8],
702
self.assertTrue(vf.has_version(u'b\xbfse'))
707
self.assertTrue(vf.has_version(parent_id_unicode))
708
self.assertTrue(vf.has_version(parent_id_utf8))
703
709
# we have _with_ghost apis to give us ghost information.
704
self.assertEqual([u'b\xbfse', u'notbxbfse'], vf.get_ancestry_with_ghosts([u'notbxbfse']))
705
self.assertEqual([u'b\xbfse'], vf.get_parents_with_ghosts(u'notbxbfse'))
706
self.assertEqual({u'b\xbfse':[],
707
u'notbxbfse':[u'b\xbfse'],
710
self.assertEqual([parent_id_utf8, 'notbxbfse'], vf.get_ancestry_with_ghosts(['notbxbfse']))
711
self.assertEqual([parent_id_utf8], vf.get_parents_with_ghosts('notbxbfse'))
712
self.assertEqual({parent_id_utf8:[],
713
'notbxbfse':[parent_id_utf8],
709
715
vf.get_graph_with_ghosts())
710
self.assertFalse(vf.has_ghost(u'b\xbfse'))
716
self.assertFalse(vf.has_ghost(parent_id_unicode))
717
self.assertFalse(vf.has_ghost(parent_id_utf8))
712
719
def test_add_lines_with_ghosts_after_normal_revs(self):
713
720
# some versioned file formats allow lines to be added with parent