~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Martin
  • Date: 2011-01-26 19:34:58 UTC
  • mto: (5609.10.1 2.3b5-dev)
  • mto: This revision was merged to the branch mainline in revision 5635.
  • Revision ID: gzlist@googlemail.com-20110126193458-o6mwxaymyinlzqjo
Blindly change all users of get_transport to address the function via the transport module

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    osutils,
35
35
    remote,
36
36
    symbol_versioning,
 
37
    transport as _mod_transport,
37
38
    urlutils,
38
39
    win32utils,
39
40
    workingtree,
56
57
    )
57
58
from bzrlib.tests.test_http import TestWithTransport_pycurl
58
59
from bzrlib.transport import (
59
 
    get_transport,
60
60
    memory,
61
61
    pathfilter,
62
62
    )
254
254
        # is the right format object found for a branch?
255
255
        # create a branch with a few known format objects.
256
256
        # this is not quite the same as
257
 
        t = get_transport(self.get_url())
 
257
        t = _mod_transport.get_transport(self.get_url())
258
258
        self.build_tree(["foo/", "bar/"], transport=t)
259
259
        def check_format(format, url):
260
260
            format.initialize(url)
261
 
            t = get_transport(url)
 
261
            t = _mod_transport.get_transport(url)
262
262
            found_format = bzrdir.BzrDirFormat.find_format(t)
263
263
            self.failUnless(isinstance(found_format, format.__class__))
264
264
        check_format(bzrdir.BzrDirFormat5(), "foo")
267
267
    def test_find_format_nothing_there(self):
268
268
        self.assertRaises(NotBranchError,
269
269
                          bzrdir.BzrDirFormat.find_format,
270
 
                          get_transport('.'))
 
270
                          _mod_transport.get_transport('.'))
271
271
 
272
272
    def test_find_format_unknown_format(self):
273
 
        t = get_transport(self.get_url())
 
273
        t = _mod_transport.get_transport(self.get_url())
274
274
        t.mkdir('.bzr')
275
275
        t.put_bytes('.bzr/branch-format', '')
276
276
        self.assertRaises(UnknownFormatError,
277
277
                          bzrdir.BzrDirFormat.find_format,
278
 
                          get_transport('.'))
 
278
                          _mod_transport.get_transport('.'))
279
279
 
280
280
    def test_register_unregister_format(self):
281
281
        format = SampleBzrDirFormat()
289
289
        # which bzrdir.open_containing will refuse (not supported)
290
290
        self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open_containing, url)
291
291
        # but open_downlevel will work
292
 
        t = get_transport(url)
 
292
        t = _mod_transport.get_transport(url)
293
293
        self.assertEqual(format.open(t), bzrdir.BzrDir.open_unsupported(url))
294
294
        # unregister the format
295
295
        bzrdir.BzrDirFormat.unregister_format(format)
681
681
        self.assertEqual(relpath, 'baz')
682
682
 
683
683
    def test_open_containing_from_transport(self):
684
 
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport,
685
 
                          get_transport(self.get_readonly_url('')))
686
 
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport,
687
 
                          get_transport(self.get_readonly_url('g/p/q')))
 
684
        self.assertRaises(NotBranchError,
 
685
            bzrdir.BzrDir.open_containing_from_transport,
 
686
            _mod_transport.get_transport(self.get_readonly_url('')))
 
687
        self.assertRaises(NotBranchError,
 
688
            bzrdir.BzrDir.open_containing_from_transport,
 
689
            _mod_transport.get_transport(self.get_readonly_url('g/p/q')))
688
690
        control = bzrdir.BzrDir.create(self.get_url())
689
691
        branch, relpath = bzrdir.BzrDir.open_containing_from_transport(
690
 
            get_transport(self.get_readonly_url('')))
 
692
            _mod_transport.get_transport(self.get_readonly_url('')))
691
693
        self.assertEqual('', relpath)
692
694
        branch, relpath = bzrdir.BzrDir.open_containing_from_transport(
693
 
            get_transport(self.get_readonly_url('g/p/q')))
 
695
            _mod_transport.get_transport(self.get_readonly_url('g/p/q')))
694
696
        self.assertEqual('g/p/q', relpath)
695
697
 
696
698
    def test_open_containing_tree_or_branch(self):
740
742
        # transport pointing at bzrdir should give a bzrdir with root transport
741
743
        # set to the given transport
742
744
        control = bzrdir.BzrDir.create(self.get_url())
743
 
        transport = get_transport(self.get_url())
 
745
        transport = _mod_transport.get_transport(self.get_url())
744
746
        opened_bzrdir = bzrdir.BzrDir.open_from_transport(transport)
745
747
        self.assertEqual(transport.base, opened_bzrdir.root_transport.base)
746
748
        self.assertIsInstance(opened_bzrdir, bzrdir.BzrDir)
747
749
 
748
750
    def test_open_from_transport_no_bzrdir(self):
749
 
        transport = get_transport(self.get_url())
 
751
        transport = _mod_transport.get_transport(self.get_url())
750
752
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport,
751
753
                          transport)
752
754
 
753
755
    def test_open_from_transport_bzrdir_in_parent(self):
754
756
        control = bzrdir.BzrDir.create(self.get_url())
755
 
        transport = get_transport(self.get_url())
 
757
        transport = _mod_transport.get_transport(self.get_url())
756
758
        transport.mkdir('subdir')
757
759
        transport = transport.clone('subdir')
758
760
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_from_transport,
822
824
 
823
825
    def test_find_bzrdirs(self):
824
826
        foo, bar, baz = self.make_foo_bar_baz()
825
 
        transport = get_transport(self.get_url())
 
827
        transport = _mod_transport.get_transport(self.get_url())
826
828
        self.assertEqualBzrdirs([baz, foo, bar],
827
829
                                bzrdir.BzrDir.find_bzrdirs(transport))
828
830
 
846
848
 
847
849
    def test_find_bzrdirs_permission_denied(self):
848
850
        foo, bar, baz = self.make_foo_bar_baz()
849
 
        transport = get_transport(self.get_url())
 
851
        transport = _mod_transport.get_transport(self.get_url())
850
852
        path_filter_server, path_filter_transport = \
851
853
            self.make_fake_permission_denied_transport(transport, ['foo'])
852
854
        # local transport
863
865
            return [s for s in transport.list_dir('') if s != 'baz']
864
866
 
865
867
        foo, bar, baz = self.make_foo_bar_baz()
866
 
        transport = get_transport(self.get_url())
 
868
        transport = _mod_transport.get_transport(self.get_url())
867
869
        self.assertEqualBzrdirs([foo, bar],
868
870
                                bzrdir.BzrDir.find_bzrdirs(transport,
869
871
                                    list_current=list_current))
878
880
                return False, bzrdir.root_transport.base
879
881
 
880
882
        foo, bar, baz = self.make_foo_bar_baz()
881
 
        transport = get_transport(self.get_url())
 
883
        transport = _mod_transport.get_transport(self.get_url())
882
884
        self.assertEqual([baz.root_transport.base, foo.root_transport.base],
883
885
                         list(bzrdir.BzrDir.find_bzrdirs(transport,
884
886
                                                         evaluate=evaluate)))
894
896
        root = self.make_repository('', shared=True)
895
897
        foo, bar, baz = self.make_foo_bar_baz()
896
898
        qux = self.make_bzrdir('foo/qux')
897
 
        transport = get_transport(self.get_url())
 
899
        transport = _mod_transport.get_transport(self.get_url())
898
900
        branches = bzrdir.BzrDir.find_branches(transport)
899
901
        self.assertEqual(baz.root_transport.base, branches[0].base)
900
902
        self.assertEqual(foo.root_transport.base, branches[1].base)
909
911
class TestMissingRepoBranchesSkipped(TestCaseWithMemoryTransport):
910
912
 
911
913
    def test_find_bzrdirs_missing_repo(self):
912
 
        transport = get_transport(self.get_url())
 
914
        transport = _mod_transport.get_transport(self.get_url())
913
915
        arepo = self.make_repository('arepo', shared=True)
914
916
        abranch_url = arepo.user_url + '/abranch'
915
917
        abranch = bzrdir.BzrDir.create(abranch_url).create_branch()
1100
1102
        controldir.ControlDirFormat.register_prober(NotBzrDirProber)
1101
1103
        try:
1102
1104
            found = bzrlib.bzrdir.BzrDirFormat.find_format(
1103
 
                get_transport(self.get_url()))
 
1105
                _mod_transport.get_transport(self.get_url()))
1104
1106
            self.assertIsInstance(found, NotBzrDirFormat)
1105
1107
        finally:
1106
1108
            controldir.ControlDirFormat.unregister_prober(NotBzrDirProber)
1142
1144
            self.get_url('foo'),
1143
1145
            force_new_tree=True,
1144
1146
            format=format)
1145
 
        t = get_transport(self.get_url('.'))
 
1147
        t = _mod_transport.get_transport(self.get_url('.'))
1146
1148
        self.assertFalse(t.has('foo'))
1147
1149
 
1148
1150
    def test_clone(self):
1445
1447
 
1446
1448
    def setUp(self):
1447
1449
        super(TestGenerateBackupName, self).setUp()
1448
 
        self._transport = get_transport(self.get_url())
 
1450
        self._transport = _mod_transport.get_transport(self.get_url())
1449
1451
        bzrdir.BzrDir.create(self.get_url(),
1450
1452
            possible_transports=[self._transport])
1451
1453
        self._bzrdir = bzrdir.BzrDir.open_from_transport(self._transport)