171
171
bzrdir.format_registry.set_default_repository(old_default)
173
def test_aliases(self):
174
a_registry = bzrdir.BzrDirFormatRegistry()
175
a_registry.register('weave', bzrdir.BzrDirFormat6,
176
'Pre-0.8 format. Slower and does not support checkouts or shared'
177
' repositories', deprecated=True)
178
a_registry.register('weavealias', bzrdir.BzrDirFormat6,
179
'Pre-0.8 format. Slower and does not support checkouts or shared'
180
' repositories', deprecated=True, alias=True)
181
self.assertEqual(frozenset(['weavealias']), a_registry.aliases())
174
184
class SampleBranch(bzrlib.branch.Branch):
175
185
"""A dummy branch for guess what, dummy use."""
591
601
self.failUnlessExists('repo/tree2/subtree')
592
602
self.failIfExists('repo/tree2/subtree/file')
604
def make_foo_bar_baz(self):
605
foo = bzrdir.BzrDir.create_branch_convenience('foo').bzrdir
606
bar = self.make_branch('foo/bar').bzrdir
607
baz = self.make_branch('baz').bzrdir
610
def test_find_bzrdirs(self):
611
foo, bar, baz = self.make_foo_bar_baz()
612
transport = get_transport(self.get_url())
613
self.assertEqualBzrdirs([baz, foo, bar],
614
bzrdir.BzrDir.find_bzrdirs(transport))
616
def test_find_bzrdirs_list_current(self):
617
def list_current(transport):
618
return [s for s in transport.list_dir('') if s != 'baz']
620
foo, bar, baz = self.make_foo_bar_baz()
621
transport = get_transport(self.get_url())
622
self.assertEqualBzrdirs([foo, bar],
623
bzrdir.BzrDir.find_bzrdirs(transport,
624
list_current=list_current))
627
def test_find_bzrdirs_evaluate(self):
628
def evaluate(bzrdir):
630
repo = bzrdir.open_repository()
631
except NoRepositoryPresent:
632
return True, bzrdir.root_transport.base
634
return False, bzrdir.root_transport.base
636
foo, bar, baz = self.make_foo_bar_baz()
637
transport = get_transport(self.get_url())
638
self.assertEqual([baz.root_transport.base, foo.root_transport.base],
639
list(bzrdir.BzrDir.find_bzrdirs(transport,
642
def assertEqualBzrdirs(self, first, second):
644
second = list(second)
645
self.assertEqual(len(first), len(second))
646
for x, y in zip(first, second):
647
self.assertEqual(x.root_transport.base, y.root_transport.base)
649
def test_find_branches(self):
650
root = self.make_repository('', shared=True)
651
foo, bar, baz = self.make_foo_bar_baz()
652
qux = self.make_bzrdir('foo/qux')
653
transport = get_transport(self.get_url())
654
branches = bzrdir.BzrDir.find_branches(transport)
655
self.assertEqual(baz.root_transport.base, branches[0].base)
656
self.assertEqual(foo.root_transport.base, branches[1].base)
657
self.assertEqual(bar.root_transport.base, branches[2].base)
659
# ensure this works without a top-level repo
660
branches = bzrdir.BzrDir.find_branches(transport.clone('foo'))
661
self.assertEqual(foo.root_transport.base, branches[0].base)
662
self.assertEqual(bar.root_transport.base, branches[1].base)
595
665
class TestMeta1DirFormat(TestCaseWithTransport):
596
666
"""Tests specific to the meta1 dir format."""