~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_controldir/test_controldir.py

  • Committer: Jelmer Vernooij
  • Date: 2011-10-04 14:08:14 UTC
  • mfrom: (6187 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6189.
  • Revision ID: jelmer@samba.org-20111004140814-cltag93d2l5j9zyf
MergeĀ lp:bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
                                    create_tree_if_local=create_tree_if_local)
102
102
        return target
103
103
 
 
104
    def test_uninitializable(self):
 
105
        if self.bzrdir_format.is_initializable():
 
106
            raise TestNotApplicable("format is initializable")
 
107
        t = self.get_transport()
 
108
        self.assertRaises(errors.UninitializableFormat,
 
109
            self.bzrdir_format.initialize, t.base)
 
110
 
104
111
    def test_create_null_workingtree(self):
105
112
        dir = self.make_bzrdir('dir1')
106
113
        dir.create_repository()
162
169
        if vfs_dir.has_workingtree():
163
170
            # This ControlDir format doesn't support ControlDirs without
164
171
            # working trees, so this test is irrelevant.
165
 
            return
 
172
            raise TestNotApplicable("format does not support "
 
173
                "control directories without working tree")
166
174
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
167
175
 
168
176
    def test_clone_bzrdir_repository_under_shared(self):
180
188
        try:
181
189
            self.make_repository('target', shared=True)
182
190
        except errors.IncompatibleFormat:
183
 
            return
 
191
            raise TestNotApplicable("repository format does not support "
 
192
                "shared repositories")
184
193
        target = dir.clone(self.get_url('target/child'))
185
194
        self.assertNotEqual(dir.transport.base, target.transport.base)
186
195
        self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
190
199
        try:
191
200
            shared_repo = self.make_repository('shared', shared=True)
192
201
        except errors.IncompatibleFormat:
193
 
            return
 
202
            raise TestNotApplicable("repository format does not support "
 
203
                "shared repositories")
194
204
        if not shared_repo._format.supports_nesting_repositories:
195
205
            raise TestNotApplicable("format does not support nesting "
196
206
                "repositories")
224
234
        try:
225
235
            shared_repo = self.make_repository('shared', shared=True)
226
236
        except errors.IncompatibleFormat:
227
 
            return
 
237
            raise TestNotApplicable("repository format does not support "
 
238
                "shared repositories")
228
239
        if not shared_repo._format.supports_nesting_repositories:
229
240
            raise TestNotApplicable("format does not support nesting "
230
241
                "repositories")
303
314
        try:
304
315
            shared_repo = self.make_repository('target', shared=True)
305
316
        except errors.IncompatibleFormat:
306
 
            return
 
317
            raise TestNotApplicable("repository format does not support "
 
318
                "shared repositories")
307
319
        if not shared_repo._format.supports_nesting_repositories:
308
320
            raise TestNotApplicable("format does not support nesting "
309
321
                "repositories")
311
323
        target = dir.clone(self.get_url('target/child'))
312
324
        self.assertNotEqual(dir.transport.base, target.transport.base)
313
325
        self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
314
 
        self.assertEqual(source.revision_history(),
315
 
                         target.open_branch().revision_history())
 
326
        self.assertEqual(source.last_revision(),
 
327
                         target.open_branch().last_revision())
316
328
 
317
329
    def test_clone_bzrdir_branch_revision(self):
318
330
        # test for revision limiting, [smoke test, not corner case checks].
389
401
    def test_clone_respects_stacked(self):
390
402
        branch = self.make_branch('parent')
391
403
        child_transport = self.get_transport('child')
392
 
        child = branch.bzrdir.clone_on_transport(child_transport,
393
 
                                                 stacked_on=branch.base)
 
404
        try:
 
405
            child = branch.bzrdir.clone_on_transport(child_transport,
 
406
                                                     stacked_on=branch.base)
 
407
        except (errors.UnstackableBranchFormat,
 
408
                errors.UnstackableRepositoryFormat):
 
409
            raise TestNotApplicable("branch or repository format do "
 
410
                "not support stacking")
394
411
        self.assertEqual(child.open_branch().get_stacked_on_url(), branch.base)
395
412
 
396
413
    def test_get_branch_reference_on_reference(self):
402
419
                target_branch=referenced_branch)
403
420
        except errors.IncompatibleFormat:
404
421
            # this is ok too, not all formats have to support references.
405
 
            return
 
422
            raise TestNotApplicable("control directory does not "
 
423
                "support branch references")
406
424
        self.assertEqual(referenced_branch.bzrdir.root_transport.abspath('') + '/',
407
425
            dir.get_branch_reference())
408
426
 
416
434
        dir = self.make_bzrdir('source')
417
435
        if dir.has_branch():
418
436
            # this format does not support branchless bzrdirs.
419
 
            return
 
437
            raise TestNotApplicable("format does not support "
 
438
                "branchless control directories")
420
439
        self.assertRaises(errors.NotBranchError, dir.get_branch_reference)
421
440
 
422
441
    def test_sprout_bzrdir_empty(self):
434
453
        try:
435
454
            self.make_repository('target', shared=True)
436
455
        except errors.IncompatibleFormat:
437
 
            return
 
456
            raise TestNotApplicable("format does not support shared "
 
457
                "repositories")
438
458
        target = dir.sprout(self.get_url('target/child'))
439
459
        self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
440
460
        target.open_branch()
451
471
        try:
452
472
            self.make_repository('target', shared=True)
453
473
        except errors.IncompatibleFormat:
454
 
            return
 
474
            raise TestNotApplicable("format does not support shared "
 
475
                "repositories")
455
476
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
456
477
        target.open_repository()
457
478
        target.open_branch()
472
493
        try:
473
494
            shared_repo = self.make_repository('target', shared=True)
474
495
        except errors.IncompatibleFormat:
475
 
            return
 
496
            raise TestNotApplicable("format does not support "
 
497
                "shared repositories")
476
498
        target = dir.sprout(self.get_url('target/child'))
477
499
        self.assertNotEqual(dir.user_transport.base, target.user_transport.base)
478
500
        self.assertTrue(shared_repo.has_revision('1'))
481
503
        try:
482
504
            shared_repo = self.make_repository('shared', shared=True)
483
505
        except errors.IncompatibleFormat:
484
 
            return
 
506
            raise TestNotApplicable("format does not support shared "
 
507
                "repositories")
485
508
        if not shared_repo._format.supports_nesting_repositories:
486
509
            raise TestNotApplicable("format does not support nesting "
487
510
                "repositories")
505
528
        try:
506
529
            shared_repo = self.make_repository('shared', shared=True)
507
530
        except errors.IncompatibleFormat:
508
 
            return
 
531
            raise TestNotApplicable("format does not support shared "
 
532
                "repositories")
509
533
        if not shared_repo._format.supports_nesting_repositories:
510
534
            raise TestNotApplicable("format does not support nesting "
511
535
                "repositories")
551
575
        try:
552
576
            shared_repo = self.make_repository('target', shared=True)
553
577
        except errors.IncompatibleFormat:
554
 
            return
 
578
            raise TestNotApplicable("format does not support shared "
 
579
                "repositories")
555
580
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
556
581
        self.assertNotEqual(
557
582
            dir.control_transport.base,
591
616
        try:
592
617
            shared_repo = self.make_repository('target', shared=True)
593
618
        except errors.IncompatibleFormat:
594
 
            return
 
619
            raise TestNotApplicable("format does not support shared "
 
620
                "repositories")
595
621
        target = dir.sprout(self.get_url('target/child'))
596
622
        self.assertTrue(shared_repo.has_revision('1'))
597
623
 
609
635
        try:
610
636
            shared_repo = self.make_repository('target', shared=True)
611
637
        except errors.IncompatibleFormat:
612
 
            return
 
638
            raise TestNotApplicable("format does not support shared "
 
639
                "repositories")
613
640
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
614
641
        self.assertNotEqual(dir.control_transport.base, target.control_transport.base)
615
642
        self.assertFalse(shared_repo.has_revision('1'))
622
649
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
623
650
                target_branch=referenced_branch)
624
651
        except errors.IncompatibleFormat:
625
 
            # this is ok too, not all formats have to support references.
626
 
            return
 
652
            raise TestNotApplicable("format does not support branch "
 
653
                "references")
627
654
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
628
655
        target = dir.sprout(self.get_url('target'))
629
656
        self.assertNotEqual(dir.transport.base, target.transport.base)
642
669
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
643
670
                target_branch=referenced_tree.branch)
644
671
        except errors.IncompatibleFormat:
645
 
            # this is ok too, not all formats have to support references.
646
 
            return
 
672
            raise TestNotApplicable("format does not support branch "
 
673
                "references")
647
674
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
648
675
        try:
649
676
            shared_repo = self.make_repository('target', shared=True)
650
677
        except errors.IncompatibleFormat:
651
 
            return
 
678
            raise TestNotApplicable("format does not support "
 
679
                "shared repositories")
652
680
        target = dir.sprout(self.get_url('target/child'))
653
681
        self.assertNotEqual(dir.transport.base, target.transport.base)
654
682
        # we want target to have a branch that is in-place.
669
697
                target_branch=referenced_tree.branch)
670
698
        except errors.IncompatibleFormat:
671
699
            # this is ok too, not all formats have to support references.
672
 
            return
 
700
            raise TestNotApplicable("format does not support "
 
701
                "branch references")
673
702
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
674
703
        try:
675
704
            shared_repo = self.make_repository('target', shared=True)
676
705
        except errors.IncompatibleFormat:
677
 
            return
 
706
            raise TestNotApplicable("format does not support shared "
 
707
                "repositories")
678
708
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
679
709
        self.assertNotEqual(dir.transport.base, target.transport.base)
680
710
        # we want target to have a branch that is in-place.
819
849
                target_branch=referenced_branch)
820
850
        except errors.IncompatibleFormat:
821
851
            # this is ok too, not all formats have to support references.
822
 
            return
 
852
            raise TestNotApplicable("format does not support "
 
853
                "branch references")
823
854
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
824
855
        tree = self.createWorkingTreeOrSkip(dir)
825
856
        self.build_tree(['source/subdir/'])
845
876
                target_branch=referenced_branch)
846
877
        except errors.IncompatibleFormat:
847
878
            # this is ok too, not all formats have to support references.
848
 
            return
 
879
            raise TestNotApplicable("format does not support "
 
880
                "branch references")
849
881
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
850
882
        tree = self.createWorkingTreeOrSkip(dir)
851
883
        self.build_tree(['source/foo'])
931
963
 
932
964
    def test_format_initialize_find_open(self):
933
965
        # loopback test to check the current format initializes to itself.
934
 
        if not self.bzrdir_format.is_supported():
 
966
        if not self.bzrdir_format.is_initializable():
935
967
            # unsupported formats are not loopback testable
936
968
            # because the default open will not open them and
937
969
            # they may not be initializable.
938
 
            return
 
970
            raise TestNotApplicable("format is not initializable")
939
971
        # for remote formats, there must be no prior assumption about the
940
972
        # network name to use - it's possible that this may somehow have got
941
973
        # in through an unisolated test though - see
970
1002
        self.assertInitializeEx(t, use_existing_dir=True)
971
1003
 
972
1004
    def test_format_initialize_on_transport_ex_use_existing_dir_False(self):
973
 
        if not self.bzrdir_format.is_supported():
974
 
            # Not initializable - not a failure either.
975
 
            return
 
1005
        if not self.bzrdir_format.is_initializable():
 
1006
            raise TestNotApplicable("format is not initializable")
976
1007
        t = self.get_transport('dir')
977
1008
        t.ensure_base()
978
1009
        self.assertRaises(errors.FileExists,
984
1015
        self.assertInitializeEx(t, create_prefix=True)
985
1016
 
986
1017
    def test_format_initialize_on_transport_ex_create_prefix_False(self):
987
 
        if not self.bzrdir_format.is_supported():
988
 
            # Not initializable - not a failure either.
989
 
            return
 
1018
        if not self.bzrdir_format.is_initializable():
 
1019
            raise TestNotApplicable("format is not initializable")
990
1020
        t = self.get_transport('missing/dir')
991
1021
        self.assertRaises(errors.NoSuchFile, self.assertInitializeEx, t,
992
1022
            create_prefix=False)
999
1029
            repo_format_name=repo_name, shared_repo=True)[0]
1000
1030
        made_repo, control = self.assertInitializeEx(t.clone('branch'),
1001
1031
            force_new_repo=True, repo_format_name=repo_name)
1002
 
        if control is None:
1003
 
            # uninitialisable format
1004
 
            return
1005
1032
        self.assertNotEqual(repo.bzrdir.root_transport.base,
1006
1033
            made_repo.bzrdir.root_transport.base)
1007
1034
 
1013
1040
            repo_format_name=repo_name, shared_repo=True)[0]
1014
1041
        made_repo, control = self.assertInitializeEx(t.clone('branch'),
1015
1042
            force_new_repo=False, repo_format_name=repo_name)
1016
 
        if control is None:
1017
 
            # uninitialisable format
1018
 
            return
1019
1043
        if not control._format.fixed_components:
1020
1044
            self.assertEqual(repo.bzrdir.root_transport.base,
1021
1045
                made_repo.bzrdir.root_transport.base)
1031
1055
        fmt = bzrdir.format_registry.make_bzrdir('1.6')
1032
1056
        repo_name = fmt.repository_format.network_name()
1033
1057
        repo, control = self.assertInitializeEx(t, repo_format_name=repo_name)
1034
 
        if control is None:
1035
 
            # uninitialisable format
1036
 
            return
1037
1058
        if self.bzrdir_format.fixed_components:
1038
1059
            # must stay with the all-in-one-format.
1039
1060
            repo_name = self.bzrdir_format.network_name()
1050
1071
            initialize_on_transport_ex.
1051
1072
        :return: the resulting repo, control dir tuple.
1052
1073
        """
1053
 
        if not self.bzrdir_format.is_supported():
1054
 
            # Not initializable - not a failure either.
1055
 
            return None, None
 
1074
        if not self.bzrdir_format.is_initializable():
 
1075
            raise TestNotApplicable("control dir format is not "
 
1076
                "initializable")
1056
1077
        repo, control, require_stacking, repo_policy = \
1057
1078
            self.bzrdir_format.initialize_on_transport_ex(t, **kwargs)
1058
1079
        if repo is not None:
1101
1122
 
1102
1123
    def test_create_branch(self):
1103
1124
        # a bzrdir can construct a branch and repository for itself.
1104
 
        if not self.bzrdir_format.is_supported():
 
1125
        if not self.bzrdir_format.is_initializable():
1105
1126
            # unsupported formats are not loopback testable
1106
1127
            # because the default open will not open them and
1107
1128
            # they may not be initializable.
1108
 
            return
 
1129
            raise TestNotApplicable("format is not initializable")
1109
1130
        t = self.get_transport()
1110
1131
        made_control = self.bzrdir_format.initialize(t.base)
1111
1132
        made_repo = made_control.create_repository()
1115
1136
 
1116
1137
    def test_create_branch_append_revisions_only(self):
1117
1138
        # a bzrdir can construct a branch and repository for itself.
1118
 
        if not self.bzrdir_format.is_supported():
 
1139
        if not self.bzrdir_format.is_initializable():
1119
1140
            # unsupported formats are not loopback testable
1120
1141
            # because the default open will not open them and
1121
1142
            # they may not be initializable.
1122
 
            return
 
1143
            raise TestNotApplicable("format is not initializable")
1123
1144
        t = self.get_transport()
1124
1145
        made_control = self.bzrdir_format.initialize(t.base)
1125
1146
        made_repo = made_control.create_repository()
1127
1148
            made_branch = made_control.create_branch(
1128
1149
                append_revisions_only=True)
1129
1150
        except errors.UpgradeRequired:
1130
 
            return
 
1151
            raise TestNotApplicable("format does not support "
 
1152
                "append_revisions_only setting")
1131
1153
        self.assertIsInstance(made_branch, bzrlib.branch.Branch)
1132
1154
        self.assertEquals(True, made_branch.get_append_revisions_only())
1133
1155
        self.assertEqual(made_control, made_branch.bzrdir)
1134
1156
 
1135
1157
    def test_open_branch(self):
1136
 
        if not self.bzrdir_format.is_supported():
 
1158
        if not self.bzrdir_format.is_initializable():
1137
1159
            # unsupported formats are not loopback testable
1138
1160
            # because the default open will not open them and
1139
1161
            # they may not be initializable.
1140
 
            return
 
1162
            raise TestNotApplicable("format is not initializable")
1141
1163
        t = self.get_transport()
1142
1164
        made_control = self.bzrdir_format.initialize(t.base)
1143
1165
        made_repo = made_control.create_repository()
1148
1170
        self.assertIsInstance(opened_branch._format, made_branch._format.__class__)
1149
1171
 
1150
1172
    def test_list_branches(self):
1151
 
        if not self.bzrdir_format.is_supported():
1152
 
            # unsupported formats are not loopback testable
1153
 
            # because the default open will not open them and
1154
 
            # they may not be initializable.
1155
 
            return
 
1173
        if not self.bzrdir_format.is_initializable():
 
1174
            raise TestNotApplicable("format is not initializable")
1156
1175
        t = self.get_transport()
1157
1176
        made_control = self.bzrdir_format.initialize(t.base)
1158
1177
        made_repo = made_control.create_repository()
1169
1188
 
1170
1189
    def test_create_repository(self):
1171
1190
        # a bzrdir can construct a repository for itself.
1172
 
        if not self.bzrdir_format.is_supported():
 
1191
        if not self.bzrdir_format.is_initializable():
1173
1192
            # unsupported formats are not loopback testable
1174
1193
            # because the default open will not open them and
1175
1194
            # they may not be initializable.
1176
 
            return
 
1195
            raise TestNotApplicable("format is not initializable")
1177
1196
        t = self.get_transport()
1178
1197
        made_control = self.bzrdir_format.initialize(t.base)
1179
1198
        made_repo = made_control.create_repository()
1184
1203
    def test_create_repository_shared(self):
1185
1204
        # a bzrdir can create a shared repository or
1186
1205
        # fail appropriately
1187
 
        if not self.bzrdir_format.is_supported():
 
1206
        if not self.bzrdir_format.is_initializable():
1188
1207
            # unsupported formats are not loopback testable
1189
1208
            # because the default open will not open them and
1190
1209
            # they may not be initializable.
1191
 
            return
 
1210
            raise TestNotApplicable("format is not initializable")
1192
1211
        t = self.get_transport()
1193
1212
        made_control = self.bzrdir_format.initialize(t.base)
1194
1213
        try:
1196
1215
        except errors.IncompatibleFormat:
1197
1216
            # Old bzrdir formats don't support shared repositories
1198
1217
            # and should raise IncompatibleFormat
1199
 
            return
 
1218
            raise TestNotApplicable("format does not support shared "
 
1219
                "repositories")
1200
1220
        self.assertTrue(made_repo.is_shared())
1201
1221
 
1202
1222
    def test_create_repository_nonshared(self):
1203
1223
        # a bzrdir can create a non-shared repository
1204
 
        if not self.bzrdir_format.is_supported():
 
1224
        if not self.bzrdir_format.is_initializable():
1205
1225
            # unsupported formats are not loopback testable
1206
1226
            # because the default open will not open them and
1207
1227
            # they may not be initializable.
1208
 
            return
 
1228
            raise TestNotApplicable("format is not initializable")
1209
1229
        t = self.get_transport()
1210
1230
        made_control = self.bzrdir_format.initialize(t.base)
1211
1231
        try:
1213
1233
        except errors.IncompatibleFormat:
1214
1234
            # Some control dir formats don't support non-shared repositories
1215
1235
            # and should raise IncompatibleFormat
1216
 
            return
 
1236
            raise TestNotApplicable("format does not support shared "
 
1237
                "repositories")
1217
1238
        self.assertFalse(made_repo.is_shared())
1218
1239
 
1219
1240
    def test_open_repository(self):
1220
 
        if not self.bzrdir_format.is_supported():
 
1241
        if not self.bzrdir_format.is_initializable():
1221
1242
            # unsupported formats are not loopback testable
1222
1243
            # because the default open will not open them and
1223
1244
            # they may not be initializable.
1224
 
            return
 
1245
            raise TestNotApplicable("format is not initializable")
1225
1246
        t = self.get_transport()
1226
1247
        made_control = self.bzrdir_format.initialize(t.base)
1227
1248
        made_repo = made_control.create_repository()
1232
1253
 
1233
1254
    def test_create_workingtree(self):
1234
1255
        # a bzrdir can construct a working tree for itself.
1235
 
        if not self.bzrdir_format.is_supported():
 
1256
        if not self.bzrdir_format.is_initializable():
1236
1257
            # unsupported formats are not loopback testable
1237
1258
            # because the default open will not open them and
1238
1259
            # they may not be initializable.
1239
 
            return
 
1260
            raise TestNotApplicable("format is not initializable")
1240
1261
        t = self.get_transport()
1241
1262
        made_control = self.bzrdir_format.initialize(t.base)
1242
1263
        made_repo = made_control.create_repository()
1247
1268
 
1248
1269
    def test_create_workingtree_revision(self):
1249
1270
        # a bzrdir can construct a working tree for itself @ a specific revision.
 
1271
        if not self.bzrdir_format.is_initializable():
 
1272
            raise TestNotApplicable("format is not initializable")
1250
1273
        t = self.get_transport()
1251
1274
        source = self.make_branch_and_tree('source')
1252
1275
        source.commit('a', rev_id='a', allow_pointless=True)
1263
1286
        self.assertEqual(['a'], made_tree.get_parent_ids())
1264
1287
 
1265
1288
    def test_open_workingtree(self):
1266
 
        if not self.bzrdir_format.is_supported():
1267
 
            # unsupported formats are not loopback testable
1268
 
            # because the default open will not open them and
1269
 
            # they may not be initializable.
1270
 
            return
 
1289
        if not self.bzrdir_format.is_initializable():
 
1290
            raise TestNotApplicable("format is not initializable")
1271
1291
        # this has to be tested with local access as we still support creating
1272
1292
        # format 6 bzrdirs
1273
1293
        t = self.get_transport()
1287
1307
    def test_get_selected_branch(self):
1288
1308
        # The segment parameters are accessible from the root transport
1289
1309
        # if a URL with segment parameters is opened.
1290
 
        if not self.bzrdir_format.is_supported():
1291
 
            # unsupported formats are not loopback testable
1292
 
            # because the default open will not open them and
1293
 
            # they may not be initializable.
1294
 
            return
 
1310
        if not self.bzrdir_format.is_initializable():
 
1311
            raise TestNotApplicable("format is not initializable")
1295
1312
        t = self.get_transport()
1296
1313
        try:
1297
1314
            made_control = self.bzrdir_format.initialize(t.base)
1305
1322
 
1306
1323
    def test_get_selected_branch_none_selected(self):
1307
1324
        # _get_selected_branch defaults to None
1308
 
        if not self.bzrdir_format.is_supported():
1309
 
            # unsupported formats are not loopback testable
1310
 
            # because the default open will not open them and
1311
 
            # they may not be initializable.
1312
 
            return
 
1325
        if not self.bzrdir_format.is_initializable():
 
1326
            raise TestNotApplicable("format is not initializable")
1313
1327
        t = self.get_transport()
1314
1328
        try:
1315
1329
            made_control = self.bzrdir_format.initialize(t.base)
1331
1345
            repo = self.make_repository('.', shared=True)
1332
1346
        except errors.IncompatibleFormat:
1333
1347
            # need a shared repository to test this.
1334
 
            return
 
1348
            raise TestNotApplicable("requires shared repository support")
1335
1349
        if not repo._format.supports_nesting_repositories:
1336
1350
            raise TestNotApplicable("requires nesting repositories")
1337
1351
        url = self.get_url('intermediate')
1359
1373
            repo = self.make_repository('.', shared=True)
1360
1374
        except errors.IncompatibleFormat:
1361
1375
            # need a shared repository to test this.
1362
 
            return
 
1376
            raise TestNotApplicable("requires format with shared repository "
 
1377
                "support")
1363
1378
        if not repo._format.supports_nesting_repositories:
1364
 
            return
 
1379
            raise TestNotApplicable("requires support for nesting "
 
1380
                "repositories")
1365
1381
        url = self.get_url('childbzrdir')
1366
1382
        self.get_transport().mkdir('childbzrdir')
1367
1383
        made_control = self.bzrdir_format.initialize(url)
1383
1399
            containing_repo = self.make_repository('.', shared=True)
1384
1400
        except errors.IncompatibleFormat:
1385
1401
            # need a shared repository to test this.
1386
 
            return
 
1402
            raise TestNotApplicable("requires support for shared "
 
1403
                "repositories")
1387
1404
        if not containing_repo._format.supports_nesting_repositories:
1388
1405
            raise TestNotApplicable("format does not support "
1389
1406
                "nesting repositories")
1399
1416
            containing_repo = self.make_repository('.', shared=True)
1400
1417
        except errors.IncompatibleFormat:
1401
1418
            # need a shared repository to test this.
1402
 
            return
 
1419
            raise TestNotApplicable("requires support for shared "
 
1420
                "repositories")
1403
1421
        if not containing_repo._format.supports_nesting_repositories:
1404
 
            return
 
1422
            raise TestNotApplicable("requires support for nesting "
 
1423
                "repositories")
1405
1424
        url = self.get_url('childrepo')
1406
1425
        self.get_transport().mkdir('childrepo')
1407
1426
        child_control = self.bzrdir_format.initialize(url)
1420
1439
            repo = self.make_repository('.', shared=True)
1421
1440
        except errors.IncompatibleFormat:
1422
1441
            # need a shared repository to test this.
1423
 
            return
 
1442
            raise TestNotApplicable("requires support for shared "
 
1443
                "repositories")
1424
1444
        if not repo._format.supports_nesting_repositories:
1425
 
            return
 
1445
            raise TestNotApplicable("requires support for nesting "
 
1446
                "repositories")
1426
1447
        url = self.get_url('intermediate')
1427
1448
        t = self.get_transport()
1428
1449
        t.mkdir('intermediate')
1526
1547
            # and thus this interaction cannot be tested at the interface
1527
1548
            # level.
1528
1549
            repo.unlock()
1529
 
            return
 
1550
            raise TestNotApplicable("format does not physically lock")
1530
1551
        # only one yes needed here: it should only be unlocking
1531
1552
        # the repo
1532
1553
        bzrlib.ui.ui_factory = CannedInputUIFactory([True])
1535
1556
        except NotImplementedError:
1536
1557
            # this bzrdir does not implement break_lock - so we cant test it.
1537
1558
            repo.unlock()
1538
 
            return
 
1559
            raise TestNotApplicable("format does not support breaking locks")
1539
1560
        lock_repo.lock_write()
1540
1561
        lock_repo.unlock()
1541
1562
        self.assertRaises(errors.LockBroken, repo.unlock)
1552
1573
            bzrlib.branch.BranchReferenceFormat().initialize(
1553
1574
                thisdir, target_branch=master)
1554
1575
        except errors.IncompatibleFormat:
1555
 
            return
 
1576
            raise TestNotApplicable("format does not support "
 
1577
                "branch references")
1556
1578
        unused_repo = thisdir.create_repository()
1557
1579
        master.lock_write()
1558
1580
        unused_repo.lock_write()
1605
1627
            # raised a LockActive because we do still have a live locked
1606
1628
            # object.
1607
1629
            tree.unlock()
1608
 
            return
 
1630
            raise TestNotApplicable("format does not support breaking locks")
1609
1631
        self.assertEqual([True],
1610
1632
                bzrlib.ui.ui_factory.responses)
1611
1633
        lock_tree = tree.bzrdir.open_workingtree()
1641
1663
    def test_find_repository_no_repository(self):
1642
1664
        # loopback test to check the current format fails to find a
1643
1665
        # share repository correctly.
1644
 
        if not self.bzrdir_format.is_supported():
 
1666
        if not self.bzrdir_format.is_initializable():
1645
1667
            # unsupported formats are not loopback testable
1646
1668
            # because the default open will not open them and
1647
1669
            # they may not be initializable.
1648
 
            return
 
1670
            raise TestNotApplicable("format is not initializable")
1649
1671
        # supported formats must be able to init and open
1650
1672
        # - do the vfs initialisation over the basic vfs transport
1651
1673
        # XXX: TODO this should become a 'bzrdirlocation' api call.