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
43
44
class TestDefaultFormat(TestCase):
45
46
def test_get_set_default_format(self):
47
private_default = repository._default_format.__class__
46
48
old_format = repository.RepositoryFormat.get_default_format()
47
self.assertTrue(isinstance(old_format, repository.RepositoryFormatKnit1))
49
self.assertTrue(isinstance(old_format, private_default))
48
50
repository.RepositoryFormat.set_default_format(SampleRepositoryFormat())
49
51
# creating a repository should now create an instrumented dir.
435
437
def test_unescape_xml(self):
436
438
"""We get some kind of error when malformed entities are passed"""
437
439
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)