38
38
from bzrlib.bundle.serializer.v4 import BundleSerializerV4
39
39
from bzrlib.branch import Branch
40
40
from bzrlib.diff import internal_diff
41
from bzrlib.errors import (BzrError, TestamentMismatch, NotABundle, BadBundle,
43
41
from bzrlib.merge import Merge3Merger
44
42
from bzrlib.repofmt import knitrepo
45
43
from bzrlib.osutils import sha_file, sha_string
106
104
elif kind == 'symlink':
107
105
ie = InventoryLink(file_id, name, parent_id)
109
raise BzrError('unknown kind %r' % kind)
107
raise errors.BzrError('unknown kind %r' % kind)
110
108
ie.text_sha1 = text_sha_1
111
109
ie.text_size = text_size
437
435
def test_non_bundle(self):
438
self.assertRaises(NotABundle, read_bundle, StringIO('#!/bin/sh\n'))
436
self.assertRaises(errors.NotABundle,
437
read_bundle, StringIO('#!/bin/sh\n'))
440
439
def test_malformed(self):
441
self.assertRaises(BadBundle, read_bundle,
440
self.assertRaises(errors.BadBundle, read_bundle,
442
441
StringIO('# Bazaar revision bundle v'))
444
443
def test_crlf_bundle(self):
446
445
read_bundle(StringIO('# Bazaar revision bundle v0.8\r\n'))
446
except errors.BadBundle:
448
447
# It is currently permitted for bundles with crlf line endings to
449
448
# make read_bundle raise a BadBundle, but this should be fixed.
450
449
# Anything else, especially NotABundle, is an error.
618
617
self.tree1.commit('removed', rev_id='a@cset-0-3')
620
619
bundle = self.get_valid_bundle('a@cset-0-2', 'a@cset-0-3')
621
self.assertRaises((TestamentMismatch,
620
self.assertRaises((errors.TestamentMismatch,
622
621
errors.VersionedFileInvalidChecksum), self.get_invalid_bundle,
623
622
'a@cset-0-2', 'a@cset-0-3')
624
623
# Check a rollup bundle
796
795
# Handle international characters
799
f = open(u'b1/with Dod\xe9', 'wb')
798
f = open(u'b1/foo', 'wb')
800
799
except UnicodeEncodeError:
801
800
raise TestSkipped("Filesystem doesn't support unicode")
808
807
u'William Dod\xe9\n').encode('utf-8'))
811
self.tree1.add([u'with Dod\xe9'], ['withdod-id'])
810
self.tree1.add([u'foo'], ['withdod-id'])
812
811
self.tree1.commit(u'i18n commit from William Dod\xe9',
813
812
rev_id='i18n-1', committer=u'William Dod\xe9')
815
if sys.platform == 'darwin':
816
from bzrlib.workingtree import WorkingTree3
817
if type(self.tree1) is WorkingTree3:
818
self.knownFailure("Bug #141438: fails for WorkingTree3 on OSX")
820
# On Mac the '\xe9' gets changed to 'e\u0301'
821
self.assertEqual([u'.bzr', u'with Dode\u0301'],
822
sorted(os.listdir(u'b1')))
823
delta = self.tree1.changes_from(self.tree1.basis_tree())
824
self.assertEqual([(u'with Dod\xe9', 'withdod-id', 'file')],
826
self.knownFailure("Mac OSX doesn't preserve unicode"
827
" combining characters.")
830
815
bundle = self.get_valid_bundle('null:', 'i18n-1')
833
f = open(u'b1/with Dod\xe9', 'wb')
818
f = open(u'b1/foo', 'wb')
834
819
f.write(u'Modified \xb5\n'.encode('utf8'))
836
821
self.tree1.commit(u'modified', rev_id='i18n-2')
838
823
bundle = self.get_valid_bundle('i18n-1', 'i18n-2')
841
self.tree1.rename_one(u'with Dod\xe9', u'B\xe5gfors')
826
self.tree1.rename_one(u'foo', u'bar')
842
827
self.tree1.commit(u'renamed, the new i18n man', rev_id='i18n-3',
843
828
committer=u'Erik B\xe5gfors')
845
830
bundle = self.get_valid_bundle('i18n-2', 'i18n-3')
848
self.tree1.remove([u'B\xe5gfors'])
833
self.tree1.remove([u'bar'])
849
834
self.tree1.commit(u'removed', rev_id='i18n-4')
851
836
bundle = self.get_valid_bundle('i18n-3', 'i18n-4')
1583
1568
record = record_iter.next()
1584
1569
self.assertEqual((None, {'foo': 'bar', 'storage_kind': 'header'},
1585
1570
'info', None, None), record)
1586
self.assertRaises(BadBundle, record_iter.next)
1571
self.assertRaises(errors.BadBundle, record_iter.next)
1589
1574
class TestReadMergeableFromUrl(TestCaseWithTransport):