/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: Andrew Bennetts
  • Date: 2008-09-12 08:02:18 UTC
  • mfrom: (3705 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3707.
  • Revision ID: andrew.bennetts@canonical.com-20080912080218-hl6l0h3mf54tgik3
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
from bzrlib.bundle.serializer.v4 import BundleSerializerV4
41
41
from bzrlib.branch import Branch
42
42
from bzrlib.diff import internal_diff
43
 
from bzrlib.errors import (BzrError, TestamentMismatch, NotABundle, BadBundle, 
44
 
                           NoSuchFile,)
45
43
from bzrlib.merge import Merge3Merger
46
44
from bzrlib.repofmt import knitrepo
47
45
from bzrlib.osutils import sha_file, sha_string
108
106
        elif kind == 'symlink':
109
107
            ie = InventoryLink(file_id, name, parent_id)
110
108
        else:
111
 
            raise BzrError('unknown kind %r' % kind)
 
109
            raise errors.BzrError('unknown kind %r' % kind)
112
110
        ie.text_sha1 = text_sha_1
113
111
        ie.text_size = text_size
114
112
        return ie
437
435
        return bundle 
438
436
 
439
437
    def test_non_bundle(self):
440
 
        self.assertRaises(NotABundle, read_bundle, StringIO('#!/bin/sh\n'))
 
438
        self.assertRaises(errors.NotABundle,
 
439
                          read_bundle, StringIO('#!/bin/sh\n'))
441
440
 
442
441
    def test_malformed(self):
443
 
        self.assertRaises(BadBundle, read_bundle, 
 
442
        self.assertRaises(errors.BadBundle, read_bundle,
444
443
                          StringIO('# Bazaar revision bundle v'))
445
444
 
446
445
    def test_crlf_bundle(self):
447
446
        try:
448
447
            read_bundle(StringIO('# Bazaar revision bundle v0.8\r\n'))
449
 
        except BadBundle:
 
448
        except errors.BadBundle:
450
449
            # It is currently permitted for bundles with crlf line endings to
451
450
            # make read_bundle raise a BadBundle, but this should be fixed.
452
451
            # Anything else, especially NotABundle, is an error.
484
483
                for inventory_id in old:
485
484
                    try:
486
485
                        old_file = old.get_file(inventory_id)
487
 
                    except NoSuchFile:
 
486
                    except errors.NoSuchFile:
488
487
                        continue
489
488
                    if old_file is None:
490
489
                        continue
620
619
        self.tree1.commit('removed', rev_id='a@cset-0-3')
621
620
        
622
621
        bundle = self.get_valid_bundle('a@cset-0-2', 'a@cset-0-3')
623
 
        self.assertRaises((TestamentMismatch,
 
622
        self.assertRaises((errors.TestamentMismatch,
624
623
            errors.VersionedFileInvalidChecksum), self.get_invalid_bundle,
625
624
            'a@cset-0-2', 'a@cset-0-3')
626
625
        # Check a rollup bundle 
798
797
        # Handle international characters
799
798
        os.mkdir('b1')
800
799
        try:
801
 
            f = open(u'b1/with Dod\xe9', 'wb')
 
800
            f = open(u'b1/with Dod\N{Euro Sign}', 'wb')
802
801
        except UnicodeEncodeError:
803
802
            raise TestSkipped("Filesystem doesn't support unicode")
804
803
 
810
809
            u'William Dod\xe9\n').encode('utf-8'))
811
810
        f.close()
812
811
 
813
 
        self.tree1.add([u'with Dod\xe9'], ['withdod-id'])
 
812
        self.tree1.add([u'with Dod\N{Euro Sign}'], ['withdod-id'])
814
813
        self.tree1.commit(u'i18n commit from William Dod\xe9',
815
814
                          rev_id='i18n-1', committer=u'William Dod\xe9')
816
815
 
817
 
        if sys.platform == 'darwin':
818
 
            from bzrlib.workingtree import WorkingTree3
819
 
            if type(self.tree1) is WorkingTree3:
820
 
                self.knownFailure("Bug #141438: fails for WorkingTree3 on OSX")
821
 
 
822
 
            # On Mac the '\xe9' gets changed to 'e\u0301'
823
 
            self.assertEqual([u'.bzr', u'with Dode\u0301'],
824
 
                             sorted(os.listdir(u'b1')))
825
 
            delta = self.tree1.changes_from(self.tree1.basis_tree())
826
 
            self.assertEqual([(u'with Dod\xe9', 'withdod-id', 'file')],
827
 
                             delta.removed)
828
 
            self.knownFailure("Mac OSX doesn't preserve unicode"
829
 
                              " combining characters.")
830
 
 
831
816
        # Add
832
817
        bundle = self.get_valid_bundle('null:', 'i18n-1')
833
818
 
834
819
        # Modified
835
 
        f = open(u'b1/with Dod\xe9', 'wb')
 
820
        f = open(u'b1/with Dod\N{Euro Sign}', 'wb')
836
821
        f.write(u'Modified \xb5\n'.encode('utf8'))
837
822
        f.close()
838
823
        self.tree1.commit(u'modified', rev_id='i18n-2')
839
824
 
840
825
        bundle = self.get_valid_bundle('i18n-1', 'i18n-2')
841
 
        
 
826
 
842
827
        # Renamed
843
 
        self.tree1.rename_one(u'with Dod\xe9', u'B\xe5gfors')
 
828
        self.tree1.rename_one(u'with Dod\N{Euro Sign}', u'B\N{Euro Sign}gfors')
844
829
        self.tree1.commit(u'renamed, the new i18n man', rev_id='i18n-3',
845
830
                          committer=u'Erik B\xe5gfors')
846
831
 
847
832
        bundle = self.get_valid_bundle('i18n-2', 'i18n-3')
848
833
 
849
834
        # Removed
850
 
        self.tree1.remove([u'B\xe5gfors'])
 
835
        self.tree1.remove([u'B\N{Euro Sign}gfors'])
851
836
        self.tree1.commit(u'removed', rev_id='i18n-4')
852
837
 
853
838
        bundle = self.get_valid_bundle('i18n-3', 'i18n-4')
1585
1570
        record = record_iter.next()
1586
1571
        self.assertEqual((None, {'foo': 'bar', 'storage_kind': 'header'},
1587
1572
            'info', None, None), record)
1588
 
        self.assertRaises(BadBundle, record_iter.next)
 
1573
        self.assertRaises(errors.BadBundle, record_iter.next)
1589
1574
 
1590
1575
 
1591
1576
class TestReadMergeableFromUrl(TestCaseWithTransport):