547
548
self.assertEqual(format.repository_format.__class__,
548
549
tree.branch.repository._format.__class__)
551
def test_make_branch_builder(self):
552
builder = self.make_branch_builder('dir')
553
self.assertIsInstance(builder, branchbuilder.BranchBuilder)
554
# Guard against regression into MemoryTransport leaking
555
# files to disk instead of keeping them in memory.
556
self.failIf(osutils.lexists('dir'))
558
def test_make_branch_builder_with_format(self):
559
# Use a repo layout that doesn't conform to a 'named' layout, to ensure
560
# that the format objects are used.
561
format = bzrdir.BzrDirMetaFormat1()
562
repo_format = weaverepo.RepositoryFormat7()
563
format.repository_format = repo_format
564
builder = self.make_branch_builder('dir', format=format)
565
the_branch = builder.get_branch()
566
# Guard against regression into MemoryTransport leaking
567
# files to disk instead of keeping them in memory.
568
self.failIf(osutils.lexists('dir'))
569
self.assertEqual(format.repository_format.__class__,
570
the_branch.repository._format.__class__)
571
self.assertEqual(repo_format.get_format_string(),
572
self.get_transport().get_bytes(
573
'dir/.bzr/repository/format'))
575
def test_make_branch_builder_with_format_name(self):
576
builder = self.make_branch_builder('dir', format='knit')
577
the_branch = builder.get_branch()
578
# Guard against regression into MemoryTransport leaking
579
# files to disk instead of keeping them in memory.
580
self.failIf(osutils.lexists('dir'))
581
dir_format = bzrdir.format_registry.make_bzrdir('knit')
582
self.assertEqual(dir_format.repository_format.__class__,
583
the_branch.repository._format.__class__)
584
self.assertEqual('Bazaar-NG Knit Repository Format 1',
585
self.get_transport().get_bytes(
586
'dir/.bzr/repository/format'))
550
588
def test_safety_net(self):
551
589
"""No test should modify the safety .bzr directory.
605
643
self.assertRaises(AssertionError, self.assertIsDirectory, 'a_file', t)
606
644
self.assertRaises(AssertionError, self.assertIsDirectory, 'not_here', t)
646
def test_make_branch_builder(self):
647
builder = self.make_branch_builder('dir')
648
rev_id = builder.build_commit()
649
self.failUnlessExists('dir')
650
a_dir = bzrdir.BzrDir.open('dir')
651
self.assertRaises(errors.NoWorkingTree, a_dir.open_workingtree)
652
a_branch = a_dir.open_branch()
653
builder_branch = builder.get_branch()
654
self.assertEqual(a_branch.base, builder_branch.base)
655
self.assertEqual((1, rev_id), builder_branch.last_revision_info())
656
self.assertEqual((1, rev_id), a_branch.last_revision_info())
609
659
class TestTestCaseTransports(TestCaseWithTransport):