101
101
create_tree_if_local=create_tree_if_local)
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)
104
111
def test_create_null_workingtree(self):
105
112
dir = self.make_bzrdir('dir1')
106
113
dir.create_repository()
162
171
if vfs_dir.has_workingtree():
163
172
# This ControlDir format doesn't support ControlDirs without
164
173
# working trees, so this test is irrelevant.
174
raise TestNotApplicable("format does not support "
175
"control directories without working tree")
166
176
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
168
178
def test_clone_bzrdir_repository_under_shared(self):
172
182
tree.commit('revision 1', rev_id='1')
173
183
dir = self.make_bzrdir('source')
174
184
repo = dir.create_repository()
185
if not repo._format.supports_nesting_repositories:
186
raise TestNotApplicable("repository format does not support "
175
188
repo.fetch(tree.branch.repository)
176
189
self.assertTrue(repo.has_revision('1'))
178
191
self.make_repository('target', shared=True)
179
192
except errors.IncompatibleFormat:
193
raise TestNotApplicable("repository format does not support "
194
"shared repositories")
181
195
target = dir.clone(self.get_url('target/child'))
182
196
self.assertNotEqual(dir.transport.base, target.transport.base)
183
197
self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
188
202
shared_repo = self.make_repository('shared', shared=True)
189
203
except errors.IncompatibleFormat:
204
raise TestNotApplicable("repository format does not support "
205
"shared repositories")
206
if not shared_repo._format.supports_nesting_repositories:
207
raise TestNotApplicable("format does not support nesting "
191
209
# Make a branch, 'commit_tree', and working tree outside of the shared
192
210
# repository, and commit some revisions to it.
193
211
tree = self.make_branch_and_tree('commit_tree')
292
314
tree.branch.repository.copy_content_into(source.repository)
293
315
tree.branch.copy_content_into(source)
295
self.make_repository('target', shared=True)
317
shared_repo = self.make_repository('target', shared=True)
296
318
except errors.IncompatibleFormat:
319
raise TestNotApplicable("repository format does not support "
320
"shared repositories")
321
if not shared_repo._format.supports_nesting_repositories:
322
raise TestNotApplicable("format does not support nesting "
298
324
dir = source.bzrdir
299
325
target = dir.clone(self.get_url('target/child'))
300
326
self.assertNotEqual(dir.transport.base, target.transport.base)
301
327
self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
302
self.assertEqual(source.revision_history(),
303
target.open_branch().revision_history())
328
self.assertEqual(source.last_revision(),
329
target.open_branch().last_revision())
305
331
def test_clone_bzrdir_branch_revision(self):
306
332
# test for revision limiting, [smoke test, not corner case checks].
369
395
repo.set_make_working_trees(False)
370
396
self.assertFalse(repo.make_working_trees())
373
a_dir = dir.clone(self.get_url('repo/a'))
398
a_dir = tree.bzrdir.clone(self.get_url('repo/a'))
399
a_branch = a_dir.open_branch()
400
# If the new control dir actually uses the repository, it should
401
# not have a working tree.
402
if not a_branch.repository.has_same_location(repo):
403
raise TestNotApplicable('new control dir does not use repository')
375
404
self.assertRaises(errors.NoWorkingTree, a_dir.open_workingtree)
377
406
def test_clone_respects_stacked(self):
378
407
branch = self.make_branch('parent')
379
408
child_transport = self.get_transport('child')
380
child = branch.bzrdir.clone_on_transport(child_transport,
381
stacked_on=branch.base)
410
child = branch.bzrdir.clone_on_transport(child_transport,
411
stacked_on=branch.base)
412
except (errors.UnstackableBranchFormat,
413
errors.UnstackableRepositoryFormat):
414
raise TestNotApplicable("branch or repository format does "
415
"not support stacking")
382
416
self.assertEqual(child.open_branch().get_stacked_on_url(), branch.base)
384
418
def test_get_branch_reference_on_reference(self):
404
439
dir = self.make_bzrdir('source')
405
440
if dir.has_branch():
406
441
# this format does not support branchless bzrdirs.
442
raise TestNotApplicable("format does not support "
443
"branchless control directories")
408
444
self.assertRaises(errors.NotBranchError, dir.get_branch_reference)
410
446
def test_sprout_bzrdir_empty(self):
411
447
dir = self.make_bzrdir('source')
412
448
target = dir.sprout(self.get_url('target'))
413
self.assertNotEqual(dir.transport.base, target.transport.base)
449
self.assertNotEqual(dir.control_transport.base, target.control_transport.base)
414
450
# creates a new repository branch and tree
415
451
target.open_repository()
416
452
target.open_branch()
430
467
target.open_workingtree()
431
468
except errors.NoWorkingTree:
432
469
# Some bzrdirs can never have working trees.
433
self.assertFalse(target._format.supports_workingtrees)
470
repo = target.find_repository()
471
self.assertFalse(repo.bzrdir._format.supports_workingtrees)
435
473
def test_sprout_bzrdir_empty_under_shared_repo_force_new(self):
436
474
# the force_new_repo parameter should force use of a new repo in an empty
461
500
shared_repo = self.make_repository('target', shared=True)
462
501
except errors.IncompatibleFormat:
502
raise TestNotApplicable("format does not support "
503
"shared repositories")
464
504
target = dir.sprout(self.get_url('target/child'))
465
self.assertNotEqual(dir.transport.base, target.transport.base)
505
self.assertNotEqual(dir.user_transport.base, target.user_transport.base)
466
506
self.assertTrue(shared_repo.has_revision('1'))
468
508
def test_sprout_bzrdir_repository_branch_both_under_shared(self):
470
510
shared_repo = self.make_repository('shared', shared=True)
471
511
except errors.IncompatibleFormat:
512
raise TestNotApplicable("format does not support shared "
514
if not shared_repo._format.supports_nesting_repositories:
515
raise TestNotApplicable("format does not support nesting "
473
517
tree = self.make_branch_and_tree('commit_tree')
474
518
self.build_tree(['commit_tree/foo'])
534
582
shared_repo = self.make_repository('target', shared=True)
535
583
except errors.IncompatibleFormat:
584
raise TestNotApplicable("format does not support shared "
537
586
target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
538
self.assertNotEqual(dir.transport.base, target.transport.base)
588
dir.control_transport.base,
589
target.control_transport.base)
539
590
self.assertFalse(shared_repo.has_revision('1'))
541
592
def test_sprout_bzrdir_repository_revision(self):
590
642
shared_repo = self.make_repository('target', shared=True)
591
643
except errors.IncompatibleFormat:
644
raise TestNotApplicable("format does not support shared "
593
646
target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
594
self.assertNotEqual(dir.transport.base, target.transport.base)
647
self.assertNotEqual(dir.control_transport.base, target.control_transport.base)
595
648
self.assertFalse(shared_repo.has_revision('1'))
597
650
def test_sprout_bzrdir_branch_reference(self):
602
655
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
603
656
target_branch=referenced_branch)
604
657
except errors.IncompatibleFormat:
605
# this is ok too, not all formats have to support references.
658
raise TestNotApplicable("format does not support branch "
607
660
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
608
661
target = dir.sprout(self.get_url('target'))
609
662
self.assertNotEqual(dir.transport.base, target.transport.base)
622
675
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
623
676
target_branch=referenced_tree.branch)
624
677
except errors.IncompatibleFormat:
625
# this is ok too, not all formats have to support references.
678
raise TestNotApplicable("format does not support branch "
627
680
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
629
682
shared_repo = self.make_repository('target', shared=True)
630
683
except errors.IncompatibleFormat:
684
raise TestNotApplicable("format does not support "
685
"shared repositories")
632
686
target = dir.sprout(self.get_url('target/child'))
633
687
self.assertNotEqual(dir.transport.base, target.transport.base)
634
688
# we want target to have a branch that is in-place.
649
703
target_branch=referenced_tree.branch)
650
704
except errors.IncompatibleFormat:
651
705
# this is ok too, not all formats have to support references.
706
raise TestNotApplicable("format does not support "
653
708
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
655
710
shared_repo = self.make_repository('target', shared=True)
656
711
except errors.IncompatibleFormat:
712
raise TestNotApplicable("format does not support shared "
658
714
target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
659
715
self.assertNotEqual(dir.transport.base, target.transport.base)
660
716
# we want target to have a branch that is in-place.
690
746
source.tags.set_tag('tag-a', 'rev-2')
691
747
except errors.TagsNotSupported:
692
748
raise TestNotApplicable('Branch format does not support tags.')
693
source.get_config().set_user_option('branch.fetch_tags', 'True')
749
source.get_config_stack().set('branch.fetch_tags', True)
694
750
# Now source has a tag not in its ancestry. Sprout its controldir.
695
751
dir = source.bzrdir
696
752
target = dir.sprout(self.get_url('target'))
707
763
source = builder.get_branch()
709
765
source.tags.set_tag('tag-a', 'missing-rev')
710
except errors.TagsNotSupported:
711
raise TestNotApplicable('Branch format does not support tags.')
766
except (errors.TagsNotSupported, errors.GhostTagsNotSupported):
767
raise TestNotApplicable('Branch format does not support tags '
768
'or tags referencing ghost revisions.')
712
769
# Now source has a tag pointing to an absent revision. Sprout its
714
771
dir = source.bzrdir
725
782
source = builder.get_branch()
727
784
source.tags.set_tag('tag-a', 'missing-rev')
728
except errors.TagsNotSupported:
729
raise TestNotApplicable('Branch format does not support tags.')
785
except (errors.TagsNotSupported, errors.GhostTagsNotSupported):
786
raise TestNotApplicable('Branch format does not support tags '
787
'or tags referencing missing revisions.')
730
788
# Now source has a tag pointing to an absent revision. Sprout its
732
790
dir = source.bzrdir
760
818
# Create a tag for B2, and for an absent rev
761
819
source.tags.set_tag('tag-non-ancestry', 'rev-b2')
820
except errors.TagsNotSupported:
821
raise TestNotApplicable('Branch format does not support tags ')
762
823
source.tags.set_tag('tag-absent', 'absent-rev')
763
except errors.TagsNotSupported:
764
raise TestNotApplicable('Branch format does not support tags.')
765
source.get_config().set_user_option('branch.fetch_tags', 'True')
824
except errors.GhostTagsNotSupported:
825
has_ghost_tag = False
828
source.get_config_stack().set('branch.fetch_tags', True)
766
829
# And ask sprout for C2
767
830
dir = source.bzrdir
768
831
target = dir.sprout(self.get_url('target'), revision_id='rev-c2')
769
832
# The tags are present
770
833
new_branch = target.open_branch()
772
{'tag-absent': 'absent-rev', 'tag-non-ancestry': 'rev-b2'},
773
new_branch.tags.get_tag_dict())
836
{'tag-absent': 'absent-rev', 'tag-non-ancestry': 'rev-b2'},
837
new_branch.tags.get_tag_dict())
840
{'tag-non-ancestry': 'rev-b2'},
841
new_branch.tags.get_tag_dict())
774
842
# And the revs for A2, B2 and C2's ancestries are present, but no
776
844
self.assertEqual(
900
970
def test_format_initialize_find_open(self):
901
971
# loopback test to check the current format initializes to itself.
902
if not self.bzrdir_format.is_supported():
972
if not self.bzrdir_format.is_initializable():
903
973
# unsupported formats are not loopback testable
904
974
# because the default open will not open them and
905
975
# they may not be initializable.
976
raise TestNotApplicable("format is not initializable")
907
977
# for remote formats, there must be no prior assumption about the
908
978
# network name to use - it's possible that this may somehow have got
909
979
# in through an unisolated test though - see
938
1008
self.assertInitializeEx(t, use_existing_dir=True)
940
1010
def test_format_initialize_on_transport_ex_use_existing_dir_False(self):
941
if not self.bzrdir_format.is_supported():
942
# Not initializable - not a failure either.
1011
if not self.bzrdir_format.is_initializable():
1012
raise TestNotApplicable("format is not initializable")
944
1013
t = self.get_transport('dir')
946
1015
self.assertRaises(errors.FileExists,
952
1021
self.assertInitializeEx(t, create_prefix=True)
954
1023
def test_format_initialize_on_transport_ex_create_prefix_False(self):
955
if not self.bzrdir_format.is_supported():
956
# Not initializable - not a failure either.
1024
if not self.bzrdir_format.is_initializable():
1025
raise TestNotApplicable("format is not initializable")
958
1026
t = self.get_transport('missing/dir')
959
1027
self.assertRaises(errors.NoSuchFile, self.assertInitializeEx, t,
960
1028
create_prefix=False)
981
1046
repo_format_name=repo_name, shared_repo=True)[0]
982
1047
made_repo, control = self.assertInitializeEx(t.clone('branch'),
983
1048
force_new_repo=False, repo_format_name=repo_name)
985
# uninitialisable format
987
1049
if not control._format.fixed_components:
988
1050
self.assertEqual(repo.bzrdir.root_transport.base,
989
1051
made_repo.bzrdir.root_transport.base)
991
def test_format_initialize_on_transport_ex_stacked_on(self):
992
# trunk is a stackable format. Note that its in the same server area
993
# which is what launchpad does, but not sufficient to exercise the
995
trunk = self.make_branch('trunk', format='1.9')
996
t = self.get_transport('stacked')
997
old_fmt = bzrdir.format_registry.make_bzrdir('pack-0.92')
998
repo_name = old_fmt.repository_format.network_name()
999
# Should end up with a 1.9 format (stackable)
1000
repo, control = self.assertInitializeEx(t, need_meta=True,
1001
repo_format_name=repo_name, stacked_on='../trunk',
1002
stack_on_pwd=t.base)
1004
# uninitialisable format
1006
self.assertLength(1, repo._fallback_repositories)
1008
def test_format_initialize_on_transport_ex_default_stack_on(self):
1009
# When initialize_on_transport_ex uses a stacked-on branch because of
1010
# a stacking policy on the target, the location of the fallback
1011
# repository is the same as the external location of the stacked-on
1013
balloon = self.make_bzrdir('balloon')
1014
if isinstance(balloon._format, bzrdir.BzrDirMetaFormat1):
1015
stack_on = self.make_branch('stack-on', format='1.9')
1017
stack_on = self.make_branch('stack-on')
1018
config = self.make_bzrdir('.').get_config()
1020
config.set_default_stack_on('stack-on')
1021
except errors.BzrError:
1022
raise TestNotApplicable('Only relevant for stackable formats.')
1023
# Initialize a bzrdir subject to the policy.
1024
t = self.get_transport('stacked')
1025
repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
1026
repo_name = repo_fmt.repository_format.network_name()
1027
repo, control = self.assertInitializeEx(
1028
t, need_meta=True, repo_format_name=repo_name, stacked_on=None)
1029
# self.addCleanup(repo.unlock)
1031
# uninitialisable format
1033
# There's one fallback repo, with a public location.
1034
self.assertLength(1, repo._fallback_repositories)
1035
fallback_repo = repo._fallback_repositories[0]
1037
stack_on.base, fallback_repo.bzrdir.root_transport.base)
1038
# The bzrdir creates a branch in stacking-capable format.
1039
new_branch = control.create_branch()
1040
self.assertTrue(new_branch._format.supports_stacking())
1042
1053
def test_format_initialize_on_transport_ex_repo_fmt_name_None(self):
1043
1054
t = self.get_transport('dir')
1044
1055
repo, control = self.assertInitializeEx(t)
1050
1061
fmt = bzrdir.format_registry.make_bzrdir('1.6')
1051
1062
repo_name = fmt.repository_format.network_name()
1052
1063
repo, control = self.assertInitializeEx(t, repo_format_name=repo_name)
1054
# uninitialisable format
1056
1064
if self.bzrdir_format.fixed_components:
1057
1065
# must stay with the all-in-one-format.
1058
1066
repo_name = self.bzrdir_format.network_name()
1059
1067
self.assertEqual(repo_name, repo._format.network_name())
1061
def assertInitializeEx(self, t, need_meta=False, **kwargs):
1069
def assertInitializeEx(self, t, **kwargs):
1062
1070
"""Execute initialize_on_transport_ex and check it succeeded correctly.
1064
1072
This involves checking that the disk objects were created, open with
1069
1077
initialize_on_transport_ex.
1070
1078
:return: the resulting repo, control dir tuple.
1072
if not self.bzrdir_format.is_supported():
1073
# Not initializable - not a failure either.
1080
if not self.bzrdir_format.is_initializable():
1081
raise TestNotApplicable("control dir format is not "
1075
1083
repo, control, require_stacking, repo_policy = \
1076
1084
self.bzrdir_format.initialize_on_transport_ex(t, **kwargs)
1077
1085
if repo is not None:
1081
1089
self.assertIsInstance(control, controldir.ControlDir)
1082
1090
opened = bzrdir.BzrDir.open(t.base)
1083
1091
expected_format = self.bzrdir_format
1084
if need_meta and expected_format.fixed_components:
1085
# Pre-metadir formats change when we are making something that
1086
# needs a metaformat, because clone is used for push.
1087
expected_format = bzrdir.BzrDirMetaFormat1()
1088
1092
if not isinstance(expected_format, RemoteBzrDirFormat):
1089
1093
self.assertEqual(control._format.network_name(),
1090
1094
expected_format.network_name())
1125
1129
def test_create_branch(self):
1126
1130
# a bzrdir can construct a branch and repository for itself.
1127
if not self.bzrdir_format.is_supported():
1131
if not self.bzrdir_format.is_initializable():
1128
1132
# unsupported formats are not loopback testable
1129
1133
# because the default open will not open them and
1130
1134
# they may not be initializable.
1135
raise TestNotApplicable("format is not initializable")
1132
1136
t = self.get_transport()
1133
1137
made_control = self.bzrdir_format.initialize(t.base)
1134
1138
made_repo = made_control.create_repository()
1136
1140
self.assertIsInstance(made_branch, bzrlib.branch.Branch)
1137
1141
self.assertEqual(made_control, made_branch.bzrdir)
1143
def test_create_branch_append_revisions_only(self):
1144
# a bzrdir can construct a branch and repository for itself.
1145
if not self.bzrdir_format.is_initializable():
1146
# unsupported formats are not loopback testable
1147
# because the default open will not open them and
1148
# they may not be initializable.
1149
raise TestNotApplicable("format is not initializable")
1150
t = self.get_transport()
1151
made_control = self.bzrdir_format.initialize(t.base)
1152
made_repo = made_control.create_repository()
1154
made_branch = made_control.create_branch(
1155
append_revisions_only=True)
1156
except errors.UpgradeRequired:
1157
raise TestNotApplicable("format does not support "
1158
"append_revisions_only setting")
1159
self.assertIsInstance(made_branch, bzrlib.branch.Branch)
1160
self.assertEquals(True, made_branch.get_append_revisions_only())
1161
self.assertEqual(made_control, made_branch.bzrdir)
1139
1163
def test_open_branch(self):
1140
if not self.bzrdir_format.is_supported():
1164
if not self.bzrdir_format.is_initializable():
1141
1165
# unsupported formats are not loopback testable
1142
1166
# because the default open will not open them and
1143
1167
# they may not be initializable.
1168
raise TestNotApplicable("format is not initializable")
1145
1169
t = self.get_transport()
1146
1170
made_control = self.bzrdir_format.initialize(t.base)
1147
1171
made_repo = made_control.create_repository()
1152
1176
self.assertIsInstance(opened_branch._format, made_branch._format.__class__)
1154
1178
def test_list_branches(self):
1155
if not self.bzrdir_format.is_supported():
1156
# unsupported formats are not loopback testable
1157
# because the default open will not open them and
1158
# they may not be initializable.
1179
if not self.bzrdir_format.is_initializable():
1180
raise TestNotApplicable("format is not initializable")
1160
1181
t = self.get_transport()
1161
1182
made_control = self.bzrdir_format.initialize(t.base)
1162
1183
made_repo = made_control.create_repository()
1172
1193
self.assertEquals([], made_control.list_branches())
1195
def test_get_branches(self):
1196
repo = self.make_repository('branch-1')
1197
target_branch = repo.bzrdir.create_branch()
1198
self.assertEqual([None], repo.bzrdir.get_branches().keys())
1174
1200
def test_create_repository(self):
1175
1201
# a bzrdir can construct a repository for itself.
1176
if not self.bzrdir_format.is_supported():
1202
if not self.bzrdir_format.is_initializable():
1177
1203
# unsupported formats are not loopback testable
1178
1204
# because the default open will not open them and
1179
1205
# they may not be initializable.
1206
raise TestNotApplicable("format is not initializable")
1181
1207
t = self.get_transport()
1182
1208
made_control = self.bzrdir_format.initialize(t.base)
1183
1209
made_repo = made_control.create_repository()
1188
1214
def test_create_repository_shared(self):
1189
1215
# a bzrdir can create a shared repository or
1190
1216
# fail appropriately
1191
if not self.bzrdir_format.is_supported():
1217
if not self.bzrdir_format.is_initializable():
1192
1218
# unsupported formats are not loopback testable
1193
1219
# because the default open will not open them and
1194
1220
# they may not be initializable.
1221
raise TestNotApplicable("format is not initializable")
1196
1222
t = self.get_transport()
1197
1223
made_control = self.bzrdir_format.initialize(t.base)
1200
1226
except errors.IncompatibleFormat:
1201
1227
# Old bzrdir formats don't support shared repositories
1202
1228
# and should raise IncompatibleFormat
1229
raise TestNotApplicable("format does not support shared "
1204
1231
self.assertTrue(made_repo.is_shared())
1206
1233
def test_create_repository_nonshared(self):
1207
1234
# a bzrdir can create a non-shared repository
1208
if not self.bzrdir_format.is_supported():
1235
if not self.bzrdir_format.is_initializable():
1209
1236
# unsupported formats are not loopback testable
1210
1237
# because the default open will not open them and
1211
1238
# they may not be initializable.
1239
raise TestNotApplicable("format is not initializable")
1213
1240
t = self.get_transport()
1214
1241
made_control = self.bzrdir_format.initialize(t.base)
1215
made_repo = made_control.create_repository(shared=False)
1243
made_repo = made_control.create_repository(shared=False)
1244
except errors.IncompatibleFormat:
1245
# Some control dir formats don't support non-shared repositories
1246
# and should raise IncompatibleFormat
1247
raise TestNotApplicable("format does not support shared "
1216
1249
self.assertFalse(made_repo.is_shared())
1218
1251
def test_open_repository(self):
1219
if not self.bzrdir_format.is_supported():
1252
if not self.bzrdir_format.is_initializable():
1220
1253
# unsupported formats are not loopback testable
1221
1254
# because the default open will not open them and
1222
1255
# they may not be initializable.
1256
raise TestNotApplicable("format is not initializable")
1224
1257
t = self.get_transport()
1225
1258
made_control = self.bzrdir_format.initialize(t.base)
1226
1259
made_repo = made_control.create_repository()
1232
1265
def test_create_workingtree(self):
1233
1266
# a bzrdir can construct a working tree for itself.
1234
if not self.bzrdir_format.is_supported():
1267
if not self.bzrdir_format.is_initializable():
1235
1268
# unsupported formats are not loopback testable
1236
1269
# because the default open will not open them and
1237
1270
# they may not be initializable.
1271
raise TestNotApplicable("format is not initializable")
1239
1272
t = self.get_transport()
1240
1273
made_control = self.bzrdir_format.initialize(t.base)
1241
1274
made_repo = made_control.create_repository()
1262
1297
self.assertEqual(['a'], made_tree.get_parent_ids())
1264
1299
def test_open_workingtree(self):
1265
if not self.bzrdir_format.is_supported():
1266
# unsupported formats are not loopback testable
1267
# because the default open will not open them and
1268
# they may not be initializable.
1300
if not self.bzrdir_format.is_initializable():
1301
raise TestNotApplicable("format is not initializable")
1270
1302
# this has to be tested with local access as we still support creating
1271
1303
# format 6 bzrdirs
1272
1304
t = self.get_transport()
1286
1318
def test_get_selected_branch(self):
1287
1319
# The segment parameters are accessible from the root transport
1288
1320
# if a URL with segment parameters is opened.
1289
if not self.bzrdir_format.is_supported():
1290
# unsupported formats are not loopback testable
1291
# because the default open will not open them and
1292
# they may not be initializable.
1321
if not self.bzrdir_format.is_initializable():
1322
raise TestNotApplicable("format is not initializable")
1294
1323
t = self.get_transport()
1296
1325
made_control = self.bzrdir_format.initialize(t.base)
1305
1334
def test_get_selected_branch_none_selected(self):
1306
1335
# _get_selected_branch defaults to None
1307
if not self.bzrdir_format.is_supported():
1308
# unsupported formats are not loopback testable
1309
# because the default open will not open them and
1310
# they may not be initializable.
1336
if not self.bzrdir_format.is_initializable():
1337
raise TestNotApplicable("format is not initializable")
1312
1338
t = self.get_transport()
1314
1340
made_control = self.bzrdir_format.initialize(t.base)
1356
1384
repo = self.make_repository('.', shared=True)
1357
1385
except errors.IncompatibleFormat:
1358
1386
# need a shared repository to test this.
1387
raise TestNotApplicable("requires format with shared repository "
1389
if not repo._format.supports_nesting_repositories:
1390
raise TestNotApplicable("requires support for nesting "
1360
1392
url = self.get_url('childbzrdir')
1361
1393
self.get_transport().mkdir('childbzrdir')
1362
1394
made_control = self.bzrdir_format.initialize(url)
1372
1404
found_repo.bzrdir.root_transport.base)
1374
1406
def test_find_repository_standalone_with_containing_shared_repository(self):
1375
# find repo inside a standalone repo inside a shared repo finds the standalone repo
1407
# find repo inside a standalone repo inside a shared repo finds the
1377
1410
containing_repo = self.make_repository('.', shared=True)
1378
1411
except errors.IncompatibleFormat:
1379
1412
# need a shared repository to test this.
1413
raise TestNotApplicable("requires support for shared "
1415
if not containing_repo._format.supports_nesting_repositories:
1416
raise TestNotApplicable("format does not support "
1417
"nesting repositories")
1381
1418
child_repo = self.make_repository('childrepo')
1382
1419
opened_control = bzrdir.BzrDir.open(self.get_url('childrepo'))
1383
1420
found_repo = opened_control.find_repository()
1390
1427
containing_repo = self.make_repository('.', shared=True)
1391
1428
except errors.IncompatibleFormat:
1392
1429
# need a shared repository to test this.
1430
raise TestNotApplicable("requires support for shared "
1432
if not containing_repo._format.supports_nesting_repositories:
1433
raise TestNotApplicable("requires support for nesting "
1394
1435
url = self.get_url('childrepo')
1395
1436
self.get_transport().mkdir('childrepo')
1396
1437
child_control = self.bzrdir_format.initialize(url)
1628
1674
def test_find_repository_no_repository(self):
1629
1675
# loopback test to check the current format fails to find a
1630
1676
# share repository correctly.
1631
if not self.bzrdir_format.is_supported():
1677
if not self.bzrdir_format.is_initializable():
1632
1678
# unsupported formats are not loopback testable
1633
1679
# because the default open will not open them and
1634
1680
# they may not be initializable.
1681
raise TestNotApplicable("format is not initializable")
1636
1682
# supported formats must be able to init and open
1637
1683
# - do the vfs initialisation over the basic vfs transport
1638
1684
# XXX: TODO this should become a 'bzrdirlocation' api call.