/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Aaron Bentley
  • Date: 2008-02-24 16:42:13 UTC
  • mfrom: (3234 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3235.
  • Revision ID: aaron@aaronbentley.com-20080224164213-eza1lzru5bwuwmmj
Merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    TestSkipped,
49
49
    test_sftp_transport
50
50
    )
51
 
from bzrlib.tests.HttpServer import HttpServer
52
 
from bzrlib.tests.HTTPTestUtil import (
 
51
from bzrlib.tests.http_server import HttpServer
 
52
from bzrlib.tests.http_utils import (
53
53
    TestCaseWithTwoWebservers,
54
54
    HTTPServerRedirecting,
55
55
    )
170
170
        finally:
171
171
            bzrdir.format_registry.set_default_repository(old_default)
172
172
 
 
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())
 
182
    
173
183
 
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')
593
603
 
 
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
 
608
        return foo, bar, baz
 
609
 
 
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))
 
615
 
 
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']
 
619
 
 
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))
 
625
 
 
626
 
 
627
    def test_find_bzrdirs_evaluate(self):
 
628
        def evaluate(bzrdir):
 
629
            try:
 
630
                repo = bzrdir.open_repository()
 
631
            except NoRepositoryPresent:
 
632
                return True, bzrdir.root_transport.base
 
633
            else:
 
634
                return False, bzrdir.root_transport.base
 
635
 
 
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,
 
640
                                                         evaluate=evaluate)))
 
641
 
 
642
    def assertEqualBzrdirs(self, first, second):
 
643
        first = list(first)
 
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)
 
648
 
 
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)
 
658
 
 
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)
 
663
 
594
664
 
595
665
class TestMeta1DirFormat(TestCaseWithTransport):
596
666
    """Tests specific to the meta1 dir format."""