~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Vincent Ladeuil
  • Date: 2011-02-10 12:37:27 UTC
  • mto: This revision was merged to the branch mainline in revision 5661.
  • Revision ID: v.ladeuil+lp@free.fr-20110210123727-8e0pu4wtlt6fj7nf
thread is already a python module, avoid confusion and use cethread instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib import (
27
27
    branch,
28
28
    bzrdir,
29
 
    config,
30
29
    controldir,
31
30
    errors,
32
31
    help_topics,
39
38
    transport as _mod_transport,
40
39
    urlutils,
41
40
    win32utils,
42
 
    workingtree_3,
43
 
    workingtree_4,
 
41
    workingtree,
44
42
    )
45
43
import bzrlib.branch
46
 
from bzrlib.errors import (
47
 
    NotBranchError,
48
 
    NoColocatedBranchSupport,
49
 
    UnknownFormatError,
50
 
    UnsupportedFormatError,
51
 
    )
 
44
from bzrlib.errors import (NotBranchError,
 
45
                           NoColocatedBranchSupport,
 
46
                           UnknownFormatError,
 
47
                           UnsupportedFormatError,
 
48
                           )
52
49
from bzrlib.tests import (
53
50
    TestCase,
54
51
    TestCaseWithMemoryTransport,
67
64
from bzrlib.transport.http._urllib import HttpTransport_urllib
68
65
from bzrlib.transport.nosmart import NoSmartTransportDecorator
69
66
from bzrlib.transport.readonly import ReadonlyTransportDecorator
70
 
from bzrlib.repofmt import knitrepo, knitpack_repo
 
67
from bzrlib.repofmt import knitrepo, weaverepo, pack_repo
71
68
 
72
69
 
73
70
class TestDefaultFormat(TestCase):
74
71
 
75
72
    def test_get_set_default_format(self):
76
73
        old_format = bzrdir.BzrDirFormat.get_default_format()
77
 
        # default is BzrDirMetaFormat1
78
 
        self.assertIsInstance(old_format, bzrdir.BzrDirMetaFormat1)
 
74
        # default is BzrDirFormat6
 
75
        self.failUnless(isinstance(old_format, bzrdir.BzrDirMetaFormat1))
79
76
        controldir.ControlDirFormat._set_default_format(SampleBzrDirFormat())
80
77
        # creating a bzr dir should now create an instrumented dir.
81
78
        try:
82
79
            result = bzrdir.BzrDir.create('memory:///')
83
 
            self.assertIsInstance(result, SampleBzrDir)
 
80
            self.failUnless(isinstance(result, SampleBzrDir))
84
81
        finally:
85
82
            controldir.ControlDirFormat._set_default_format(old_format)
86
83
        self.assertEqual(old_format, bzrdir.BzrDirFormat.get_default_format())
87
84
 
88
85
 
89
 
class DeprecatedBzrDirFormat(bzrdir.BzrDirFormat):
90
 
    """A deprecated bzr dir format."""
91
 
 
92
 
 
93
86
class TestFormatRegistry(TestCase):
94
87
 
95
88
    def make_format_registry(self):
96
89
        my_format_registry = controldir.ControlDirFormatRegistry()
97
 
        my_format_registry.register('deprecated', DeprecatedBzrDirFormat,
98
 
            'Some format.  Slower and unawesome and deprecated.',
99
 
            deprecated=True)
100
 
        my_format_registry.register_lazy('lazy', 'bzrlib.tests.test_bzrdir',
101
 
            'DeprecatedBzrDirFormat', 'Format registered lazily',
102
 
            deprecated=True)
 
90
        my_format_registry.register('weave', bzrdir.BzrDirFormat6,
 
91
            'Pre-0.8 format.  Slower and does not support checkouts or shared'
 
92
            ' repositories', deprecated=True)
 
93
        my_format_registry.register_lazy('lazy', 'bzrlib.bzrdir',
 
94
            'BzrDirFormat6', 'Format registered lazily', deprecated=True)
103
95
        bzrdir.register_metadir(my_format_registry, 'knit',
104
96
            'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
105
97
            'Format using knits',
116
108
            'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
117
109
            'Experimental successor to knit.  Use at your own risk.',
118
110
            branch_format='bzrlib.branch.BzrBranchFormat6', hidden=True)
119
 
        my_format_registry.register('hiddendeprecated', DeprecatedBzrDirFormat,
120
 
            'Old format.  Slower and does not support things. ', hidden=True)
121
 
        my_format_registry.register_lazy('hiddenlazy', 'bzrlib.tests.test_bzrdir',
122
 
            'DeprecatedBzrDirFormat', 'Format registered lazily',
123
 
            deprecated=True, hidden=True)
 
111
        my_format_registry.register('hiddenweave', bzrdir.BzrDirFormat6,
 
112
            'Pre-0.8 format.  Slower and does not support checkouts or shared'
 
113
            ' repositories', hidden=True)
 
114
        my_format_registry.register_lazy('hiddenlazy', 'bzrlib.bzrdir',
 
115
            'BzrDirFormat6', 'Format registered lazily', deprecated=True,
 
116
            hidden=True)
124
117
        return my_format_registry
125
118
 
126
119
    def test_format_registry(self):
127
120
        my_format_registry = self.make_format_registry()
128
121
        my_bzrdir = my_format_registry.make_bzrdir('lazy')
129
 
        self.assertIsInstance(my_bzrdir, DeprecatedBzrDirFormat)
130
 
        my_bzrdir = my_format_registry.make_bzrdir('deprecated')
131
 
        self.assertIsInstance(my_bzrdir, DeprecatedBzrDirFormat)
 
122
        self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6)
 
123
        my_bzrdir = my_format_registry.make_bzrdir('weave')
 
124
        self.assertIsInstance(my_bzrdir, bzrdir.BzrDirFormat6)
132
125
        my_bzrdir = my_format_registry.make_bzrdir('default')
133
126
        self.assertIsInstance(my_bzrdir.repository_format,
134
127
            knitrepo.RepositoryFormatKnit1)
147
140
                         my_format_registry.get_help('knit'))
148
141
        self.assertEqual('Format using knits',
149
142
                         my_format_registry.get_help('default'))
150
 
        self.assertEqual('Some format.  Slower and unawesome and deprecated.',
151
 
                         my_format_registry.get_help('deprecated'))
 
143
        self.assertEqual('Pre-0.8 format.  Slower and does not support'
 
144
                         ' checkouts or shared repositories',
 
145
                         my_format_registry.get_help('weave'))
152
146
 
153
147
    def test_help_topic(self):
154
148
        topics = help_topics.HelpTopicRegistry()
178
172
            self.assertIs(bzrdir.format_registry.get('dirstate-with-subtree'),
179
173
                          bzrdir.format_registry.get('default'))
180
174
            self.assertIs(
181
 
                repository.format_registry.get_default().__class__,
 
175
                repository.RepositoryFormat.get_default_format().__class__,
182
176
                knitrepo.RepositoryFormatKnit3)
183
177
        finally:
184
178
            bzrdir.format_registry.set_default_repository(old_default)
185
179
 
186
180
    def test_aliases(self):
187
181
        a_registry = controldir.ControlDirFormatRegistry()
188
 
        a_registry.register('deprecated', DeprecatedBzrDirFormat,
189
 
            'Old format.  Slower and does not support stuff',
190
 
            deprecated=True)
191
 
        a_registry.register('deprecatedalias', DeprecatedBzrDirFormat,
192
 
            'Old format.  Slower and does not support stuff',
193
 
            deprecated=True, alias=True)
194
 
        self.assertEqual(frozenset(['deprecatedalias']), a_registry.aliases())
 
182
        a_registry.register('weave', bzrdir.BzrDirFormat6,
 
183
            'Pre-0.8 format.  Slower and does not support checkouts or shared'
 
184
            ' repositories', deprecated=True)
 
185
        a_registry.register('weavealias', bzrdir.BzrDirFormat6,
 
186
            'Pre-0.8 format.  Slower and does not support checkouts or shared'
 
187
            ' repositories', deprecated=True, alias=True)
 
188
        self.assertEqual(frozenset(['weavealias']), a_registry.aliases())
195
189
 
196
190
 
197
191
class SampleBranch(bzrlib.branch.Branch):
254
248
        return "opened branch."
255
249
 
256
250
 
257
 
class BzrDirFormatTest1(bzrdir.BzrDirMetaFormat1):
258
 
 
259
 
    @staticmethod
260
 
    def get_format_string():
261
 
        return "Test format 1"
262
 
 
263
 
 
264
 
class BzrDirFormatTest2(bzrdir.BzrDirMetaFormat1):
265
 
 
266
 
    @staticmethod
267
 
    def get_format_string():
268
 
        return "Test format 2"
269
 
 
270
 
 
271
251
class TestBzrDirFormat(TestCaseWithTransport):
272
252
    """Tests for the BzrDirFormat facility."""
273
253
 
274
254
    def test_find_format(self):
275
255
        # is the right format object found for a branch?
276
256
        # create a branch with a few known format objects.
277
 
        bzrdir.BzrProber.formats.register(BzrDirFormatTest1.get_format_string(),
278
 
            BzrDirFormatTest1())
279
 
        self.addCleanup(bzrdir.BzrProber.formats.remove,
280
 
            BzrDirFormatTest1.get_format_string())
281
 
        bzrdir.BzrProber.formats.register(BzrDirFormatTest2.get_format_string(),
282
 
            BzrDirFormatTest2())
283
 
        self.addCleanup(bzrdir.BzrProber.formats.remove,
284
 
            BzrDirFormatTest2.get_format_string())
 
257
        # this is not quite the same as
285
258
        t = self.get_transport()
286
259
        self.build_tree(["foo/", "bar/"], transport=t)
287
260
        def check_format(format, url):
288
261
            format.initialize(url)
289
 
            t = _mod_transport.get_transport_from_path(url)
 
262
            t = _mod_transport.get_transport(url)
290
263
            found_format = bzrdir.BzrDirFormat.find_format(t)
291
 
            self.assertIsInstance(found_format, format.__class__)
292
 
        check_format(BzrDirFormatTest1(), "foo")
293
 
        check_format(BzrDirFormatTest2(), "bar")
 
264
            self.failUnless(isinstance(found_format, format.__class__))
 
265
        check_format(bzrdir.BzrDirFormat5(), "foo")
 
266
        check_format(bzrdir.BzrDirFormat6(), "bar")
294
267
 
295
268
    def test_find_format_nothing_there(self):
296
269
        self.assertRaises(NotBranchError,
297
270
                          bzrdir.BzrDirFormat.find_format,
298
 
                          _mod_transport.get_transport_from_path('.'))
 
271
                          _mod_transport.get_transport('.'))
299
272
 
300
273
    def test_find_format_unknown_format(self):
301
274
        t = self.get_transport()
303
276
        t.put_bytes('.bzr/branch-format', '')
304
277
        self.assertRaises(UnknownFormatError,
305
278
                          bzrdir.BzrDirFormat.find_format,
306
 
                          _mod_transport.get_transport_from_path('.'))
 
279
                          _mod_transport.get_transport('.'))
307
280
 
308
281
    def test_register_unregister_format(self):
309
282
        format = SampleBzrDirFormat()
311
284
        # make a bzrdir
312
285
        format.initialize(url)
313
286
        # register a format for it.
314
 
        bzrdir.BzrProber.formats.register(format.get_format_string(), format)
 
287
        bzrdir.BzrDirFormat.register_format(format)
315
288
        # which bzrdir.Open will refuse (not supported)
316
289
        self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open, url)
317
290
        # which bzrdir.open_containing will refuse (not supported)
318
291
        self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open_containing, url)
319
292
        # but open_downlevel will work
320
 
        t = _mod_transport.get_transport_from_url(url)
 
293
        t = _mod_transport.get_transport(url)
321
294
        self.assertEqual(format.open(t), bzrdir.BzrDir.open_unsupported(url))
322
295
        # unregister the format
323
 
        bzrdir.BzrProber.formats.remove(format.get_format_string())
 
296
        bzrdir.BzrDirFormat.unregister_format(format)
324
297
        # now open_downlevel should fail too.
325
298
        self.assertRaises(UnknownFormatError, bzrdir.BzrDir.open_unsupported, url)
326
299
 
503
476
    def test_default_stacking_with_stackable_branch_unstackable_repo(self):
504
477
        # Make stackable source branch with an unstackable repo format.
505
478
        source_bzrdir = self.make_bzrdir('source')
506
 
        knitpack_repo.RepositoryFormatKnitPack1().initialize(source_bzrdir)
 
479
        pack_repo.RepositoryFormatKnitPack1().initialize(source_bzrdir)
507
480
        source_branch = bzrlib.branch.BzrBranchFormat7().initialize(
508
481
            source_bzrdir)
509
482
        # Make a directory with a default stacking policy
711
684
    def test_open_containing_from_transport(self):
712
685
        self.assertRaises(NotBranchError,
713
686
            bzrdir.BzrDir.open_containing_from_transport,
714
 
            _mod_transport.get_transport_from_url(self.get_readonly_url('')))
 
687
            _mod_transport.get_transport(self.get_readonly_url('')))
715
688
        self.assertRaises(NotBranchError,
716
689
            bzrdir.BzrDir.open_containing_from_transport,
717
 
            _mod_transport.get_transport_from_url(
718
 
                self.get_readonly_url('g/p/q')))
 
690
            _mod_transport.get_transport(self.get_readonly_url('g/p/q')))
719
691
        control = bzrdir.BzrDir.create(self.get_url())
720
692
        branch, relpath = bzrdir.BzrDir.open_containing_from_transport(
721
 
            _mod_transport.get_transport_from_url(
722
 
                self.get_readonly_url('')))
 
693
            _mod_transport.get_transport(self.get_readonly_url('')))
723
694
        self.assertEqual('', relpath)
724
695
        branch, relpath = bzrdir.BzrDir.open_containing_from_transport(
725
 
            _mod_transport.get_transport_from_url(
726
 
                self.get_readonly_url('g/p/q')))
 
696
            _mod_transport.get_transport(self.get_readonly_url('g/p/q')))
727
697
        self.assertEqual('g/p/q', relpath)
728
698
 
729
699
    def test_open_containing_tree_or_branch(self):
802
772
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
803
773
        tree2.lock_read()
804
774
        self.addCleanup(tree2.unlock)
805
 
        self.assertPathExists('tree2/subtree/file')
 
775
        self.failUnlessExists('tree2/subtree/file')
806
776
        self.assertEqual('tree-reference', tree2.kind('subtree-root'))
807
777
 
808
778
    def test_cloning_metadir(self):
812
782
        branch = self.make_branch('branch', format='knit')
813
783
        format = branch.bzrdir.cloning_metadir()
814
784
        self.assertIsInstance(format.workingtree_format,
815
 
            workingtree_4.WorkingTreeFormat6)
 
785
            workingtree.WorkingTreeFormat3)
816
786
 
817
787
    def test_sprout_recursive_treeless(self):
818
788
        tree = self.make_branch_and_tree('tree1',
842
812
        # #634470.  -- vila 20100909
843
813
        self.assertRaises(errors.NotBranchError,
844
814
                          tree.bzrdir.sprout, 'repo/tree2')
845
 
#        self.assertPathExists('repo/tree2/subtree')
846
 
#        self.assertPathDoesNotExist('repo/tree2/subtree/file')
 
815
#        self.failUnlessExists('repo/tree2/subtree')
 
816
#        self.failIfExists('repo/tree2/subtree/file')
847
817
 
848
818
    def make_foo_bar_baz(self):
849
819
        foo = bzrdir.BzrDir.create_branch_convenience('foo').bzrdir
902
872
        def evaluate(bzrdir):
903
873
            try:
904
874
                repo = bzrdir.open_repository()
905
 
            except errors.NoRepositoryPresent:
 
875
            except NoRepositoryPresent:
906
876
                return True, bzrdir.root_transport.base
907
877
            else:
908
878
                return False, bzrdir.root_transport.base
962
932
                         dir.get_branch_transport(bzrlib.branch.BzrBranchFormat5()).base)
963
933
        repository_base = t.clone('repository').base
964
934
        self.assertEqual(repository_base, dir.get_repository_transport(None).base)
965
 
        repository_format = repository.format_registry.get_default()
966
935
        self.assertEqual(repository_base,
967
 
                         dir.get_repository_transport(repository_format).base)
 
936
                         dir.get_repository_transport(weaverepo.RepositoryFormat7()).base)
968
937
        checkout_base = t.clone('checkout').base
969
938
        self.assertEqual(checkout_base, dir.get_workingtree_transport(None).base)
970
939
        self.assertEqual(checkout_base,
971
 
                         dir.get_workingtree_transport(workingtree_3.WorkingTreeFormat3()).base)
 
940
                         dir.get_workingtree_transport(workingtree.WorkingTreeFormat3()).base)
972
941
 
973
942
    def test_meta1dir_uses_lockdir(self):
974
943
        """Meta1 format uses a LockDir to guard the whole directory, not a file."""
1016
985
        self.assertEqual(2, rpc_count)
1017
986
 
1018
987
 
 
988
class TestFormat5(TestCaseWithTransport):
 
989
    """Tests specific to the version 5 bzrdir format."""
 
990
 
 
991
    def test_same_lockfiles_between_tree_repo_branch(self):
 
992
        # this checks that only a single lockfiles instance is created
 
993
        # for format 5 objects
 
994
        dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
 
995
        def check_dir_components_use_same_lock(dir):
 
996
            ctrl_1 = dir.open_repository().control_files
 
997
            ctrl_2 = dir.open_branch().control_files
 
998
            ctrl_3 = dir.open_workingtree()._control_files
 
999
            self.assertTrue(ctrl_1 is ctrl_2)
 
1000
            self.assertTrue(ctrl_2 is ctrl_3)
 
1001
        check_dir_components_use_same_lock(dir)
 
1002
        # and if we open it normally.
 
1003
        dir = bzrdir.BzrDir.open(self.get_url())
 
1004
        check_dir_components_use_same_lock(dir)
 
1005
 
 
1006
    def test_can_convert(self):
 
1007
        # format 5 dirs are convertable
 
1008
        dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
 
1009
        self.assertTrue(dir.can_convert_format())
 
1010
 
 
1011
    def test_needs_conversion(self):
 
1012
        # format 5 dirs need a conversion if they are not the default,
 
1013
        # and they aren't
 
1014
        dir = bzrdir.BzrDirFormat5().initialize(self.get_url())
 
1015
        # don't need to convert it to itself
 
1016
        self.assertFalse(dir.needs_format_conversion(bzrdir.BzrDirFormat5()))
 
1017
        # do need to convert it to the current default
 
1018
        self.assertTrue(dir.needs_format_conversion(
 
1019
            bzrdir.BzrDirFormat.get_default_format()))
 
1020
 
 
1021
 
 
1022
class TestFormat6(TestCaseWithTransport):
 
1023
    """Tests specific to the version 6 bzrdir format."""
 
1024
 
 
1025
    def test_same_lockfiles_between_tree_repo_branch(self):
 
1026
        # this checks that only a single lockfiles instance is created
 
1027
        # for format 6 objects
 
1028
        dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
 
1029
        def check_dir_components_use_same_lock(dir):
 
1030
            ctrl_1 = dir.open_repository().control_files
 
1031
            ctrl_2 = dir.open_branch().control_files
 
1032
            ctrl_3 = dir.open_workingtree()._control_files
 
1033
            self.assertTrue(ctrl_1 is ctrl_2)
 
1034
            self.assertTrue(ctrl_2 is ctrl_3)
 
1035
        check_dir_components_use_same_lock(dir)
 
1036
        # and if we open it normally.
 
1037
        dir = bzrdir.BzrDir.open(self.get_url())
 
1038
        check_dir_components_use_same_lock(dir)
 
1039
 
 
1040
    def test_can_convert(self):
 
1041
        # format 6 dirs are convertable
 
1042
        dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
 
1043
        self.assertTrue(dir.can_convert_format())
 
1044
 
 
1045
    def test_needs_conversion(self):
 
1046
        # format 6 dirs need an conversion if they are not the default.
 
1047
        dir = bzrdir.BzrDirFormat6().initialize(self.get_url())
 
1048
        self.assertTrue(dir.needs_format_conversion(
 
1049
            bzrdir.BzrDirFormat.get_default_format()))
 
1050
 
 
1051
 
 
1052
class NotBzrDir(bzrlib.bzrdir.BzrDir):
 
1053
    """A non .bzr based control directory."""
 
1054
 
 
1055
    def __init__(self, transport, format):
 
1056
        self._format = format
 
1057
        self.root_transport = transport
 
1058
        self.transport = transport.clone('.not')
 
1059
 
 
1060
 
 
1061
class NotBzrDirFormat(bzrlib.bzrdir.BzrDirFormat):
 
1062
    """A test class representing any non-.bzr based disk format."""
 
1063
 
 
1064
    def initialize_on_transport(self, transport):
 
1065
        """Initialize a new .not dir in the base directory of a Transport."""
 
1066
        transport.mkdir('.not')
 
1067
        return self.open(transport)
 
1068
 
 
1069
    def open(self, transport):
 
1070
        """Open this directory."""
 
1071
        return NotBzrDir(transport, self)
 
1072
 
 
1073
    @classmethod
 
1074
    def _known_formats(self):
 
1075
        return set([NotBzrDirFormat()])
 
1076
 
 
1077
 
 
1078
class NotBzrDirProber(controldir.Prober):
 
1079
 
 
1080
    def probe_transport(self, transport):
 
1081
        """Our format is present if the transport ends in '.not/'."""
 
1082
        if transport.has('.not'):
 
1083
            return NotBzrDirFormat()
 
1084
 
 
1085
 
 
1086
class TestNotBzrDir(TestCaseWithTransport):
 
1087
    """Tests for using the bzrdir api with a non .bzr based disk format.
 
1088
 
 
1089
    If/when one of these is in the core, we can let the implementation tests
 
1090
    verify this works.
 
1091
    """
 
1092
 
 
1093
    def test_create_and_find_format(self):
 
1094
        # create a .notbzr dir
 
1095
        format = NotBzrDirFormat()
 
1096
        dir = format.initialize(self.get_url())
 
1097
        self.assertIsInstance(dir, NotBzrDir)
 
1098
        # now probe for it.
 
1099
        controldir.ControlDirFormat.register_prober(NotBzrDirProber)
 
1100
        try:
 
1101
            found = bzrlib.bzrdir.BzrDirFormat.find_format(self.get_transport())
 
1102
            self.assertIsInstance(found, NotBzrDirFormat)
 
1103
        finally:
 
1104
            controldir.ControlDirFormat.unregister_prober(NotBzrDirProber)
 
1105
 
 
1106
    def test_included_in_known_formats(self):
 
1107
        not_format = NotBzrDirFormat()
 
1108
        bzrlib.controldir.ControlDirFormat.register_format(not_format)
 
1109
        try:
 
1110
            formats = bzrlib.bzrdir.BzrDirFormat.known_formats()
 
1111
            for format in formats:
 
1112
                if isinstance(format, NotBzrDirFormat):
 
1113
                    return
 
1114
            self.fail("No NotBzrDirFormat in %s" % formats)
 
1115
        finally:
 
1116
            bzrlib.controldir.ControlDirFormat.unregister_format(not_format)
 
1117
 
 
1118
 
1019
1119
class NonLocalTests(TestCaseWithTransport):
1020
1120
    """Tests for bzrdir static behaviour on non local paths."""
1021
1121
 
1062
1162
        my_bzrdir = bzrdir.BzrDir.open(self.get_url('branch-knit2'))
1063
1163
        checkout_format = my_bzrdir.checkout_metadir()
1064
1164
        self.assertIsInstance(checkout_format.workingtree_format,
1065
 
                              workingtree_4.WorkingTreeFormat4)
 
1165
                              workingtree.WorkingTreeFormat3)
1066
1166
 
1067
1167
 
1068
1168
class TestHTTPRedirections(object):
1212
1312
 
1213
1313
    def __init__(self, *args, **kwargs):
1214
1314
        super(_TestBzrDir, self).__init__(*args, **kwargs)
1215
 
        self.test_branch = _TestBranch(self.transport)
 
1315
        self.test_branch = _TestBranch()
1216
1316
        self.test_branch.repository = self.create_repository()
1217
1317
 
1218
1318
    def open_branch(self, unsupported=False):
1229
1329
class _TestBranch(bzrlib.branch.Branch):
1230
1330
    """Test Branch implementation for TestBzrDirSprout."""
1231
1331
 
1232
 
    def __init__(self, transport, *args, **kwargs):
 
1332
    def __init__(self, *args, **kwargs):
1233
1333
        self._format = _TestBranchFormat()
1234
 
        self._transport = transport
1235
 
        self.base = transport.base
1236
1334
        super(_TestBranch, self).__init__(*args, **kwargs)
1237
1335
        self.calls = []
1238
1336
        self._parent = None
1239
1337
 
1240
1338
    def sprout(self, *args, **kwargs):
1241
1339
        self.calls.append('sprout')
1242
 
        return _TestBranch(self._transport)
 
1340
        return _TestBranch()
1243
1341
 
1244
1342
    def copy_content_into(self, destination, revision_id=None):
1245
1343
        self.calls.append('copy_content_into')
1250
1348
    def get_parent(self):
1251
1349
        return self._parent
1252
1350
 
1253
 
    def _get_config(self):
1254
 
        return config.TransportConfig(self._transport, 'branch.conf')
1255
 
 
1256
1351
    def set_parent(self, parent):
1257
1352
        self._parent = parent
1258
1353
 
1367
1462
    def test_exiting(self):
1368
1463
        self._transport.put_bytes("a.~1~", "some content")
1369
1464
        self.assertEqual("a.~2~", self._bzrdir._available_backup_name("a"))
1370