~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_versionedfile.py

  • Committer: Brad Crittenden
  • Date: 2007-02-26 20:56:10 UTC
  • mfrom: (2300 +trunk)
  • mto: (2293.1.5 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 2311.
  • Revision ID: brad.crittenden@canonical.com-20070226205610-44oatbxrjjz3ajwy
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)
248
248
 
668
668
        # add_lines_with_ghosts api.
669
669
        vf = self.get_file()
670
670
        # add a revision with ghost parents
 
671
        # The preferred form is utf8, but we should translate when needed
 
672
        parent_id_unicode = u'b\xbfse'
 
673
        parent_id_utf8 = parent_id_unicode.encode('utf8')
671
674
        try:
672
 
            vf.add_lines_with_ghosts(u'notbxbfse', [u'b\xbfse'], [])
 
675
            vf.add_lines_with_ghosts(u'notbxbfse', [parent_id_utf8], [])
673
676
        except NotImplementedError:
674
677
            # check the other ghost apis are also not implemented
675
678
            self.assertRaises(NotImplementedError, vf.has_ghost, 'foo')
681
684
        # test key graph related apis: getncestry, _graph, get_parents
682
685
        # has_version
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],
700
705
                          },
701
706
                         vf.get_graph())
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],
708
714
                          },
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))
711
718
 
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