38
38
from bzrlib.transport import get_transport
39
39
from bzrlib.transport.http import HttpServer
40
40
from bzrlib.transport.memory import MemoryServer
41
from bzrlib import upgrade, workingtree
44
43
class TestDefaultFormat(TestCase):
46
45
def test_get_set_default_format(self):
47
private_default = repository._default_format.__class__
48
46
old_format = repository.RepositoryFormat.get_default_format()
49
self.assertTrue(isinstance(old_format, private_default))
47
self.assertTrue(isinstance(old_format, repository.RepositoryFormatKnit1))
50
48
repository.RepositoryFormat.set_default_format(SampleRepositoryFormat())
51
49
# creating a repository should now create an instrumented dir.
74
72
def initialize(self, a_bzrdir, shared=False):
75
73
"""Initialize a repository in a BzrDir"""
76
74
t = a_bzrdir.get_repository_transport(self)
77
t.put_bytes('format', self.get_format_string())
75
t.put('format', StringIO(self.get_format_string()))
78
76
return 'A bzr repository dir'
80
78
def is_supported(self):
437
435
def test_unescape_xml(self):
438
436
"""We get some kind of error when malformed entities are passed"""
439
437
self.assertRaises(KeyError, repository._unescape_xml, 'foo&bar;')
442
class TestRepositoryFormatKnit2(TestCaseWithTransport):
444
def test_convert(self):
445
"""Ensure the upgrade adds weaves for roots"""
446
format = bzrdir.BzrDirMetaFormat1()
447
format.repository_format = repository.RepositoryFormatKnit1()
448
tree = self.make_branch_and_tree('.', format)
449
tree.commit("Dull commit", rev_id="dull")
450
revision_tree = tree.branch.repository.revision_tree('dull')
451
self.assertRaises(errors.NoSuchFile, revision_tree.get_file_lines,
452
revision_tree.inventory.root.file_id)
453
format = bzrdir.BzrDirMetaFormat1()
454
format.repository_format = repository.RepositoryFormatKnit2()
455
upgrade.Convert('.', format)
456
tree = workingtree.WorkingTree.open('.')
457
revision_tree = tree.branch.repository.revision_tree('dull')
458
revision_tree.get_file_lines(revision_tree.inventory.root.file_id)
459
tree.commit("Another dull commit", rev_id='dull2')
460
revision_tree = tree.branch.repository.revision_tree('dull2')
461
self.assertEqual('dull', revision_tree.inventory.root.revision)