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,
45
43
from bzrlib.merge import Merge3Merger
46
44
from bzrlib.repofmt import knitrepo
47
45
from bzrlib.osutils import sha_file, sha_string
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'))
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'))
446
445
def test_crlf_bundle(self):
448
447
read_bundle(StringIO('# Bazaar revision bundle v0.8\r\n'))
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.
620
619
self.tree1.commit('removed', rev_id='a@cset-0-3')
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
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")
810
809
u'William Dod\xe9\n').encode('utf-8'))
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')
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")
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')],
828
self.knownFailure("Mac OSX doesn't preserve unicode"
829
" combining characters.")
832
817
bundle = self.get_valid_bundle('null:', 'i18n-1')
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'))
838
823
self.tree1.commit(u'modified', rev_id='i18n-2')
840
825
bundle = self.get_valid_bundle('i18n-1', 'i18n-2')
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')
847
832
bundle = self.get_valid_bundle('i18n-2', 'i18n-3')
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')
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)
1591
1576
class TestReadMergeableFromUrl(TestCaseWithTransport):