~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/bzrdir_implementations/test_bzrdir.py

MergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import bzrlib.branch
24
24
import bzrlib.bzrdir as bzrdir
25
25
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
 
26
from bzrlib.check import check
26
27
from bzrlib.commit import commit
27
28
import bzrlib.errors as errors
28
29
from bzrlib.errors import (FileExists,
32
33
                           NotBranchError,
33
34
                           )
34
35
import bzrlib.repository as repository
35
 
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
 
36
from bzrlib.tests import (
 
37
                          ChrootedTestCase,
 
38
                          TestCase,
 
39
                          TestCaseWithTransport,
 
40
                          TestSkipped,
 
41
                          )
36
42
from bzrlib.trace import mutter
37
43
import bzrlib.transactions as transactions
38
44
import bzrlib.transport as transport
39
45
from bzrlib.transport import get_transport
 
46
import bzrlib.ui as ui
40
47
from bzrlib.upgrade import upgrade
41
48
import bzrlib.workingtree as workingtree
42
49
 
105
112
        self.assertNotEqual(dir.transport.base, target.transport.base)
106
113
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
107
114
    
 
115
    def test_clone_bzrdir_empty_force_new_ignored(self):
 
116
        # the force_new_repo parameter should have no effect on an empty
 
117
        # bzrdir's clone logic
 
118
        dir = self.make_bzrdir('source')
 
119
        target = dir.clone(self.get_url('target'), force_new_repo=True)
 
120
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
121
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
 
122
    
108
123
    def test_clone_bzrdir_repository(self):
109
124
        dir = self.make_bzrdir('source')
110
125
        repo = dir.create_repository()
118
133
        self.assertNotEqual(dir.transport.base, target.transport.base)
119
134
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
120
135
 
 
136
    def test_clone_bzrdir_repository_under_shared(self):
 
137
        dir = self.make_bzrdir('source')
 
138
        repo = dir.create_repository()
 
139
        # add some content to differentiate from an empty repository.
 
140
        repo.control_weaves.add_text('inventory',
 
141
                                     "A",
 
142
                                     [],
 
143
                                     [],
 
144
                                     repo.get_transaction())
 
145
        try:
 
146
            self.make_repository('target', shared=True)
 
147
        except errors.IncompatibleFormat:
 
148
            return
 
149
        target = dir.clone(self.get_url('target/child'))
 
150
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
151
        self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
 
152
 
 
153
    def test_clone_bzrdir_repository_branch_both_under_shared(self):
 
154
        try:
 
155
            shared_repo = self.make_repository('shared', shared=True)
 
156
        except errors.IncompatibleFormat:
 
157
            return
 
158
        tree = self.make_branch_and_tree('commit_tree')
 
159
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
160
        tree.add('foo')
 
161
        tree.commit('revision 1', rev_id='1')
 
162
        tree.bzrdir.open_branch().set_revision_history([])
 
163
        tree.set_last_revision(None)
 
164
        tree.commit('revision 2', rev_id='2')
 
165
        tree.bzrdir.open_repository().copy_content_into(shared_repo)
 
166
        dir = self.make_bzrdir('shared/source')
 
167
        dir.create_branch()
 
168
        target = dir.clone(self.get_url('shared/target'))
 
169
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
170
        self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base)
 
171
        self.assertTrue(shared_repo.has_revision('1'))
 
172
        
 
173
    def test_clone_bzrdir_repository_under_shared_force_new_repo(self):
 
174
        dir = self.make_bzrdir('source')
 
175
        repo = dir.create_repository()
 
176
        # add some content to differentiate from an empty repository.
 
177
        repo.control_weaves.add_text('inventory',
 
178
                                     "A",
 
179
                                     [],
 
180
                                     [],
 
181
                                     repo.get_transaction())
 
182
        try:
 
183
            self.make_repository('target', shared=True)
 
184
        except errors.IncompatibleFormat:
 
185
            return
 
186
        target = dir.clone(self.get_url('target/child'), force_new_repo=True)
 
187
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
188
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
 
189
 
121
190
    def test_clone_bzrdir_repository_revision(self):
122
191
        # test for revision limiting, [smoke test, not corner case checks].
123
192
        # make a repository with some revisions,
150
219
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
151
220
                                    ['./.bzr/stat-cache', './.bzr/checkout/stat-cache'])
152
221
 
 
222
    def test_clone_bzrdir_branch_and_repo_into_shared_repo(self):
 
223
        # by default cloning into a shared repo uses the shared repo.
 
224
        tree = self.make_branch_and_tree('commit_tree')
 
225
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
226
        tree.add('foo')
 
227
        tree.commit('revision 1')
 
228
        source = self.make_branch('source')
 
229
        tree.bzrdir.open_repository().copy_content_into(source.repository)
 
230
        tree.bzrdir.open_branch().copy_content_into(source)
 
231
        try:
 
232
            self.make_repository('target', shared=True)
 
233
        except errors.IncompatibleFormat:
 
234
            return
 
235
        dir = source.bzrdir
 
236
        target = dir.clone(self.get_url('target/child'))
 
237
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
238
        self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
 
239
        self.assertEqual(source.revision_history(),
 
240
                         target.open_branch().revision_history())
 
241
 
 
242
    def test_clone_bzrdir_branch_and_repo_into_shared_repo_force_new_repo(self):
 
243
        # by default cloning into a shared repo uses the shared repo.
 
244
        tree = self.make_branch_and_tree('commit_tree')
 
245
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
246
        tree.add('foo')
 
247
        tree.commit('revision 1')
 
248
        source = self.make_branch('source')
 
249
        tree.bzrdir.open_repository().copy_content_into(source.repository)
 
250
        tree.bzrdir.open_branch().copy_content_into(source)
 
251
        try:
 
252
            self.make_repository('target', shared=True)
 
253
        except errors.IncompatibleFormat:
 
254
            return
 
255
        dir = source.bzrdir
 
256
        target = dir.clone(self.get_url('target/child'), force_new_repo=True)
 
257
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
258
        target.open_repository()
 
259
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
 
260
 
153
261
    def test_clone_bzrdir_branch_reference(self):
154
262
        # cloning should preserve the reference status of the branch in a bzrdir
155
263
        referenced_branch = self.make_branch('referencced')
265
373
        target.open_repository()
266
374
        target.open_branch()
267
375
        target.open_workingtree()
 
376
 
 
377
    def test_sprout_bzrdir_empty_under_shared_repo(self):
 
378
        # sprouting an empty dir into a repo uses the repo
 
379
        dir = self.make_bzrdir('source')
 
380
        try:
 
381
            self.make_repository('target', shared=True)
 
382
        except errors.IncompatibleFormat:
 
383
            return
 
384
        target = dir.sprout(self.get_url('target/child'))
 
385
        self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
 
386
        target.open_branch()
 
387
        target.open_workingtree()
 
388
 
 
389
    def test_sprout_bzrdir_empty_under_shared_repo(self):
 
390
        # the force_new_repo parameter should force use of a new repo in an empty
 
391
        # bzrdir's sprout logic
 
392
        dir = self.make_bzrdir('source')
 
393
        try:
 
394
            self.make_repository('target', shared=True)
 
395
        except errors.IncompatibleFormat:
 
396
            return
 
397
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
 
398
        target.open_repository()
 
399
        target.open_branch()
 
400
        target.open_workingtree()
268
401
    
269
402
    def test_sprout_bzrdir_repository(self):
270
403
        dir = self.make_bzrdir('source')
279
412
        self.assertNotEqual(dir.transport.base, target.transport.base)
280
413
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
281
414
 
 
415
    def test_sprout_bzrdir_with_repository_to_shared(self):
 
416
        tree = self.make_branch_and_tree('commit_tree')
 
417
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
418
        tree.add('foo')
 
419
        tree.commit('revision 1', rev_id='1')
 
420
        tree.bzrdir.open_branch().set_revision_history([])
 
421
        tree.set_last_revision(None)
 
422
        tree.commit('revision 2', rev_id='2')
 
423
        source = self.make_repository('source')
 
424
        tree.bzrdir.open_repository().copy_content_into(source)
 
425
        dir = source.bzrdir
 
426
        try:
 
427
            shared_repo = self.make_repository('target', shared=True)
 
428
        except errors.IncompatibleFormat:
 
429
            return
 
430
        target = dir.sprout(self.get_url('target/child'))
 
431
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
432
        self.assertTrue(shared_repo.has_revision('1'))
 
433
 
 
434
    def test_sprout_bzrdir_repository_branch_both_under_shared(self):
 
435
        try:
 
436
            shared_repo = self.make_repository('shared', shared=True)
 
437
        except errors.IncompatibleFormat:
 
438
            return
 
439
        tree = self.make_branch_and_tree('commit_tree')
 
440
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
441
        tree.add('foo')
 
442
        tree.commit('revision 1', rev_id='1')
 
443
        tree.bzrdir.open_branch().set_revision_history([])
 
444
        tree.set_last_revision(None)
 
445
        tree.commit('revision 2', rev_id='2')
 
446
        tree.bzrdir.open_repository().copy_content_into(shared_repo)
 
447
        dir = self.make_bzrdir('shared/source')
 
448
        dir.create_branch()
 
449
        target = dir.sprout(self.get_url('shared/target'))
 
450
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
451
        self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base)
 
452
        self.assertTrue(shared_repo.has_revision('1'))
 
453
 
 
454
    def test_sprout_bzrdir_repository_under_shared_force_new_repo(self):
 
455
        tree = self.make_branch_and_tree('commit_tree')
 
456
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
457
        tree.add('foo')
 
458
        tree.commit('revision 1', rev_id='1')
 
459
        tree.bzrdir.open_branch().set_revision_history([])
 
460
        tree.set_last_revision(None)
 
461
        tree.commit('revision 2', rev_id='2')
 
462
        source = self.make_repository('source')
 
463
        tree.bzrdir.open_repository().copy_content_into(source)
 
464
        dir = source.bzrdir
 
465
        try:
 
466
            shared_repo = self.make_repository('target', shared=True)
 
467
        except errors.IncompatibleFormat:
 
468
            return
 
469
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
 
470
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
471
        self.assertFalse(shared_repo.has_revision('1'))
 
472
 
282
473
    def test_sprout_bzrdir_repository_revision(self):
283
474
        # test for revision limiting, [smoke test, not corner case checks].
284
475
        # make a repository with some revisions,
310
501
        self.assertNotEqual(dir.transport.base, target.transport.base)
311
502
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
312
503
 
 
504
    def test_sprout_bzrdir_branch_and_repo_shared(self):
 
505
        # sprouting a branch with a repo into a shared repo uses the shared
 
506
        # repo
 
507
        tree = self.make_branch_and_tree('commit_tree')
 
508
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
509
        tree.add('foo')
 
510
        tree.commit('revision 1', rev_id='1')
 
511
        source = self.make_branch('source')
 
512
        tree.bzrdir.open_repository().copy_content_into(source.repository)
 
513
        tree.bzrdir.open_branch().copy_content_into(source)
 
514
        dir = source.bzrdir
 
515
        try:
 
516
            shared_repo = self.make_repository('target', shared=True)
 
517
        except errors.IncompatibleFormat:
 
518
            return
 
519
        target = dir.sprout(self.get_url('target/child'))
 
520
        self.assertTrue(shared_repo.has_revision('1'))
 
521
 
 
522
    def test_sprout_bzrdir_branch_and_repo_shared_force_new_repo(self):
 
523
        # sprouting a branch with a repo into a shared repo uses the shared
 
524
        # repo
 
525
        tree = self.make_branch_and_tree('commit_tree')
 
526
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
527
        tree.add('foo')
 
528
        tree.commit('revision 1', rev_id='1')
 
529
        source = self.make_branch('source')
 
530
        tree.bzrdir.open_repository().copy_content_into(source.repository)
 
531
        tree.bzrdir.open_branch().copy_content_into(source)
 
532
        dir = source.bzrdir
 
533
        try:
 
534
            shared_repo = self.make_repository('target', shared=True)
 
535
        except errors.IncompatibleFormat:
 
536
            return
 
537
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
 
538
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
539
        self.assertFalse(shared_repo.has_revision('1'))
 
540
 
313
541
    def test_sprout_bzrdir_branch_reference(self):
314
542
        # sprouting should create a repository if needed and a sprouted branch.
315
543
        referenced_branch = self.make_branch('referencced')
329
557
        # place
330
558
        target.open_repository()
331
559
 
 
560
    def test_sprout_bzrdir_branch_reference_shared(self):
 
561
        # sprouting should create a repository if needed and a sprouted branch.
 
562
        referenced_tree = self.make_branch_and_tree('referenced')
 
563
        referenced_tree.commit('1', rev_id='1', allow_pointless=True)
 
564
        dir = self.make_bzrdir('source')
 
565
        try:
 
566
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
 
567
                referenced_tree.branch)
 
568
        except errors.IncompatibleFormat:
 
569
            # this is ok too, not all formats have to support references.
 
570
            return
 
571
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
 
572
        try:
 
573
            shared_repo = self.make_repository('target', shared=True)
 
574
        except errors.IncompatibleFormat:
 
575
            return
 
576
        target = dir.sprout(self.get_url('target/child'))
 
577
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
578
        # we want target to have a branch that is in-place.
 
579
        self.assertEqual(target, target.open_branch().bzrdir)
 
580
        # and we want no repository as the target is shared
 
581
        self.assertRaises(errors.NoRepositoryPresent, 
 
582
                          target.open_repository)
 
583
        # and we want revision '1' in the shared repo
 
584
        self.assertTrue(shared_repo.has_revision('1'))
 
585
 
 
586
    def test_sprout_bzrdir_branch_reference_shared_force_new_repo(self):
 
587
        # sprouting should create a repository if needed and a sprouted branch.
 
588
        referenced_tree = self.make_branch_and_tree('referenced')
 
589
        referenced_tree.commit('1', rev_id='1', allow_pointless=True)
 
590
        dir = self.make_bzrdir('source')
 
591
        try:
 
592
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
 
593
                referenced_tree.branch)
 
594
        except errors.IncompatibleFormat:
 
595
            # this is ok too, not all formats have to support references.
 
596
            return
 
597
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
 
598
        try:
 
599
            shared_repo = self.make_repository('target', shared=True)
 
600
        except errors.IncompatibleFormat:
 
601
            return
 
602
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
 
603
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
604
        # we want target to have a branch that is in-place.
 
605
        self.assertEqual(target, target.open_branch().bzrdir)
 
606
        # and we want revision '1' in the new repo
 
607
        self.assertTrue(target.open_repository().has_revision('1'))
 
608
        # but not the shared one
 
609
        self.assertFalse(shared_repo.has_revision('1'))
 
610
 
332
611
    def test_sprout_bzrdir_branch_revision(self):
333
612
        # test for revision limiting, [smoke test, not corner case checks].
334
613
        # make a repository with some revisions,
472
751
                          get_transport(self.get_readonly_url()))
473
752
 
474
753
    def test_create_branch(self):
475
 
        # a bzrdir can construct a repository for itself.
 
754
        # a bzrdir can construct a branch and repository for itself.
476
755
        if not self.bzrdir_format.is_supported():
477
756
            # unsupported formats are not loopback testable
478
757
            # because the default open will not open them and
642
921
        self.assertEqual(dir.root_transport.base,
643
922
                         get_transport(self.get_url('.')).base)
644
923
 
 
924
    def test_find_repository_no_repo_under_standalone_branch(self):
 
925
        # finding a repo stops at standalone branches even if there is a
 
926
        # higher repository available.
 
927
        try:
 
928
            repo = self.make_repository('.', shared=True)
 
929
        except errors.IncompatibleFormat:
 
930
            # need a shared repository to test this.
 
931
            return
 
932
        url = self.get_url('intermediate')
 
933
        get_transport(self.get_url()).mkdir('intermediate')
 
934
        get_transport(self.get_url()).mkdir('intermediate/child')
 
935
        made_control = self.bzrdir_format.initialize(url)
 
936
        made_control.create_repository()
 
937
        innermost_control = self.bzrdir_format.initialize(
 
938
            self.get_url('intermediate/child'))
 
939
        try:
 
940
            child_repo = innermost_control.open_repository()
 
941
            # if there is a repository, then the format cannot ever hit this 
 
942
            # code path.
 
943
            return
 
944
        except errors.NoRepositoryPresent:
 
945
            pass
 
946
        self.assertRaises(errors.NoRepositoryPresent,
 
947
                          innermost_control.find_repository)
 
948
 
 
949
    def test_find_repository_containing_shared_repository(self):
 
950
        # find repo inside a shared repo with an empty control dir
 
951
        # returns the shared repo.
 
952
        try:
 
953
            repo = self.make_repository('.', shared=True)
 
954
        except errors.IncompatibleFormat:
 
955
            # need a shared repository to test this.
 
956
            return
 
957
        url = self.get_url('childbzrdir')
 
958
        get_transport(self.get_url()).mkdir('childbzrdir')
 
959
        made_control = self.bzrdir_format.initialize(url)
 
960
        try:
 
961
            child_repo = made_control.open_repository()
 
962
            # if there is a repository, then the format cannot ever hit this 
 
963
            # code path.
 
964
            return
 
965
        except errors.NoRepositoryPresent:
 
966
            pass
 
967
        found_repo = made_control.find_repository()
 
968
        self.assertEqual(repo.bzrdir.root_transport.base,
 
969
                         found_repo.bzrdir.root_transport.base)
 
970
        
 
971
    def test_find_repository_standalone_with_containing_shared_repository(self):
 
972
        # find repo inside a standalone repo inside a shared repo finds the standalone repo
 
973
        try:
 
974
            containing_repo = self.make_repository('.', shared=True)
 
975
        except errors.IncompatibleFormat:
 
976
            # need a shared repository to test this.
 
977
            return
 
978
        child_repo = self.make_repository('childrepo')
 
979
        opened_control = bzrdir.BzrDir.open(self.get_url('childrepo'))
 
980
        found_repo = opened_control.find_repository()
 
981
        self.assertEqual(child_repo.bzrdir.root_transport.base,
 
982
                         found_repo.bzrdir.root_transport.base)
 
983
 
 
984
    def test_find_repository_shared_within_shared_repository(self):
 
985
        # find repo at a shared repo inside a shared repo finds the inner repo
 
986
        try:
 
987
            containing_repo = self.make_repository('.', shared=True)
 
988
        except errors.IncompatibleFormat:
 
989
            # need a shared repository to test this.
 
990
            return
 
991
        url = self.get_url('childrepo')
 
992
        get_transport(self.get_url()).mkdir('childrepo')
 
993
        child_control = self.bzrdir_format.initialize(url)
 
994
        child_repo = child_control.create_repository(shared=True)
 
995
        opened_control = bzrdir.BzrDir.open(self.get_url('childrepo'))
 
996
        found_repo = opened_control.find_repository()
 
997
        self.assertEqual(child_repo.bzrdir.root_transport.base,
 
998
                         found_repo.bzrdir.root_transport.base)
 
999
        self.assertNotEqual(child_repo.bzrdir.root_transport.base,
 
1000
                            containing_repo.bzrdir.root_transport.base)
 
1001
 
 
1002
    def test_find_repository_with_nested_dirs_works(self):
 
1003
        # find repo inside a bzrdir inside a bzrdir inside a shared repo 
 
1004
        # finds the outer shared repo.
 
1005
        try:
 
1006
            repo = self.make_repository('.', shared=True)
 
1007
        except errors.IncompatibleFormat:
 
1008
            # need a shared repository to test this.
 
1009
            return
 
1010
        url = self.get_url('intermediate')
 
1011
        get_transport(self.get_url()).mkdir('intermediate')
 
1012
        get_transport(self.get_url()).mkdir('intermediate/child')
 
1013
        made_control = self.bzrdir_format.initialize(url)
 
1014
        try:
 
1015
            child_repo = made_control.open_repository()
 
1016
            # if there is a repository, then the format cannot ever hit this 
 
1017
            # code path.
 
1018
            return
 
1019
        except errors.NoRepositoryPresent:
 
1020
            pass
 
1021
        innermost_control = self.bzrdir_format.initialize(
 
1022
            self.get_url('intermediate/child'))
 
1023
        try:
 
1024
            child_repo = innermost_control.open_repository()
 
1025
            # if there is a repository, then the format cannot ever hit this 
 
1026
            # code path.
 
1027
            return
 
1028
        except errors.NoRepositoryPresent:
 
1029
            pass
 
1030
        found_repo = innermost_control.find_repository()
 
1031
        self.assertEqual(repo.bzrdir.root_transport.base,
 
1032
                         found_repo.bzrdir.root_transport.base)
 
1033
        
 
1034
    def test_can_and_needs_format_conversion(self):
 
1035
        # check that we can ask an instance if its upgradable
 
1036
        dir = self.make_bzrdir('.')
 
1037
        if dir.can_convert_format():
 
1038
            # if its updatable there must be an updater
 
1039
            self.assertTrue(isinstance(dir._format.get_converter(),
 
1040
                                       bzrdir.Converter))
 
1041
        dir.needs_format_conversion(None)
 
1042
 
 
1043
    def test_upgrade_new_instance(self):
 
1044
        """Does an available updater work ?."""
 
1045
        dir = self.make_bzrdir('.')
 
1046
        if dir.can_convert_format():
 
1047
            dir._format.get_converter(None).convert(dir, ui.ui_factory.progress_bar())
 
1048
            # and it should pass 'check' now.
 
1049
            check(bzrdir.BzrDir.open(self.get_url('.')).open_branch(), False)
 
1050
 
 
1051
 
 
1052
class ChrootedBzrDirTests(ChrootedTestCase):
 
1053
 
 
1054
    def test_find_repository_no_repository(self):
 
1055
        # loopback test to check the current format fails to find a 
 
1056
        # share repository correctly.
 
1057
        if not self.bzrdir_format.is_supported():
 
1058
            # unsupported formats are not loopback testable
 
1059
            # because the default open will not open them and
 
1060
            # they may not be initializable.
 
1061
            return
 
1062
        # supported formats must be able to init and open
 
1063
        url = self.get_url('subdir')
 
1064
        get_transport(self.get_url()).mkdir('subdir')
 
1065
        made_control = self.bzrdir_format.initialize(url)
 
1066
        try:
 
1067
            repo = made_control.open_repository()
 
1068
            # if there is a repository, then the format cannot ever hit this 
 
1069
            # code path.
 
1070
            return
 
1071
        except errors.NoRepositoryPresent:
 
1072
            pass
 
1073
        opened_control = bzrdir.BzrDir.open(self.get_readonly_url('subdir'))
 
1074
        self.assertRaises(errors.NoRepositoryPresent,
 
1075
                          opened_control.find_repository)
 
1076