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)
111
def test_multiple_initialization(self):
112
# loopback test to check the current format initializes to itself.
113
if not self.bzrdir_format.is_initializable():
114
# unsupported formats are not loopback testable
115
# because the default open will not open them and
116
# they may not be initializable.
117
raise TestNotApplicable("format is not initializable")
118
self.bzrdir_format.initialize('.')
119
self.assertRaises(errors.AlreadyControlDirError,
120
self.bzrdir_format.initialize, '.')
104
122
def test_create_null_workingtree(self):
105
123
dir = self.make_bzrdir('dir1')
106
124
dir.create_repository()
107
125
dir.create_branch()
109
wt = dir.create_workingtree(revision_id=bzrlib.revision.NULL_REVISION)
127
wt = dir.create_workingtree(revision_id=_mod_revision.NULL_REVISION)
110
128
except (errors.NotLocalUrl, errors.UnsupportedOperation):
111
129
raise TestSkipped("cannot make working tree with transport %r"
172
201
tree.commit('revision 1', rev_id='1')
173
202
dir = self.make_bzrdir('source')
174
203
repo = dir.create_repository()
204
if not repo._format.supports_nesting_repositories:
205
raise TestNotApplicable("repository format does not support "
175
207
repo.fetch(tree.branch.repository)
176
208
self.assertTrue(repo.has_revision('1'))
178
210
self.make_repository('target', shared=True)
179
211
except errors.IncompatibleFormat:
212
raise TestNotApplicable("repository format does not support "
213
"shared repositories")
181
214
target = dir.clone(self.get_url('target/child'))
182
215
self.assertNotEqual(dir.transport.base, target.transport.base)
183
216
self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
219
256
shared_repo = self.make_repository('shared', shared=True)
220
257
except errors.IncompatibleFormat:
258
raise TestNotApplicable("repository format does not support "
259
"shared repositories")
260
if not shared_repo._format.supports_nesting_repositories:
261
raise TestNotApplicable("format does not support nesting "
222
263
tree = self.make_branch_and_tree('commit_tree')
223
264
self.build_tree(['commit_tree/foo'])
225
266
tree.commit('revision 1', rev_id='1')
226
267
tree.branch.bzrdir.open_branch().generate_revision_history(
227
bzrlib.revision.NULL_REVISION)
268
_mod_revision.NULL_REVISION)
228
269
tree.set_parent_trees([])
229
270
tree.commit('revision 2', rev_id='2')
230
271
tree.branch.repository.copy_content_into(shared_repo)
292
333
tree.branch.repository.copy_content_into(source.repository)
293
334
tree.branch.copy_content_into(source)
295
self.make_repository('target', shared=True)
336
shared_repo = self.make_repository('target', shared=True)
296
337
except errors.IncompatibleFormat:
338
raise TestNotApplicable("repository format does not support "
339
"shared repositories")
340
if not shared_repo._format.supports_nesting_repositories:
341
raise TestNotApplicable("format does not support nesting "
298
343
dir = source.bzrdir
299
344
target = dir.clone(self.get_url('target/child'))
300
345
self.assertNotEqual(dir.transport.base, target.transport.base)
301
346
self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
302
self.assertEqual(source.revision_history(),
303
target.open_branch().revision_history())
347
self.assertEqual(source.last_revision(),
348
target.open_branch().last_revision())
305
350
def test_clone_bzrdir_branch_revision(self):
306
351
# test for revision limiting, [smoke test, not corner case checks].
369
414
repo.set_make_working_trees(False)
370
415
self.assertFalse(repo.make_working_trees())
373
a_dir = dir.clone(self.get_url('repo/a'))
417
a_dir = tree.bzrdir.clone(self.get_url('repo/a'))
418
a_branch = a_dir.open_branch()
419
# If the new control dir actually uses the repository, it should
420
# not have a working tree.
421
if not a_branch.repository.has_same_location(repo):
422
raise TestNotApplicable('new control dir does not use repository')
375
423
self.assertRaises(errors.NoWorkingTree, a_dir.open_workingtree)
377
425
def test_clone_respects_stacked(self):
378
426
branch = self.make_branch('parent')
379
427
child_transport = self.get_transport('child')
380
child = branch.bzrdir.clone_on_transport(child_transport,
381
stacked_on=branch.base)
429
child = branch.bzrdir.clone_on_transport(child_transport,
430
stacked_on=branch.base)
431
except (errors.UnstackableBranchFormat,
432
errors.UnstackableRepositoryFormat):
433
raise TestNotApplicable("branch or repository format does "
434
"not support stacking")
382
435
self.assertEqual(child.open_branch().get_stacked_on_url(), branch.base)
437
def test_set_branch_reference(self):
438
"""set_branch_reference creates a branch reference"""
439
referenced_branch = self.make_branch('referenced')
440
dir = self.make_bzrdir('source')
442
reference = dir.set_branch_reference(referenced_branch)
443
except errors.IncompatibleFormat:
444
# this is ok too, not all formats have to support references.
445
raise TestNotApplicable("control directory does not "
446
"support branch references")
448
referenced_branch.bzrdir.root_transport.abspath('') + '/',
449
dir.get_branch_reference())
451
def test_set_branch_reference_on_existing_reference(self):
452
"""set_branch_reference creates a branch reference"""
453
referenced_branch1 = self.make_branch('old-referenced')
454
referenced_branch2 = self.make_branch('new-referenced')
455
dir = self.make_bzrdir('source')
457
reference = dir.set_branch_reference(referenced_branch1)
458
except errors.IncompatibleFormat:
459
# this is ok too, not all formats have to support references.
460
raise TestNotApplicable("control directory does not "
461
"support branch references")
462
reference = dir.set_branch_reference(referenced_branch2)
464
referenced_branch2.bzrdir.root_transport.abspath('') + '/',
465
dir.get_branch_reference())
467
def test_set_branch_reference_on_existing_branch(self):
468
"""set_branch_reference creates a branch reference"""
469
referenced_branch = self.make_branch('referenced')
470
dir = self.make_branch('source').bzrdir
472
reference = dir.set_branch_reference(referenced_branch)
473
except errors.IncompatibleFormat:
474
# this is ok too, not all formats have to support references.
475
raise TestNotApplicable("control directory does not "
476
"support branch references")
478
referenced_branch.bzrdir.root_transport.abspath('') + '/',
479
dir.get_branch_reference())
384
481
def test_get_branch_reference_on_reference(self):
385
482
"""get_branch_reference should return the right url."""
386
483
referenced_branch = self.make_branch('referenced')
387
484
dir = self.make_bzrdir('source')
389
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
390
target_branch=referenced_branch)
486
dir.set_branch_reference(referenced_branch)
391
487
except errors.IncompatibleFormat:
392
488
# this is ok too, not all formats have to support references.
489
raise TestNotApplicable("control directory does not "
490
"support branch references")
394
491
self.assertEqual(referenced_branch.bzrdir.root_transport.abspath('') + '/',
395
492
dir.get_branch_reference())
461
562
shared_repo = self.make_repository('target', shared=True)
462
563
except errors.IncompatibleFormat:
564
raise TestNotApplicable("format does not support "
565
"shared repositories")
464
566
target = dir.sprout(self.get_url('target/child'))
465
self.assertNotEqual(dir.transport.base, target.transport.base)
567
self.assertNotEqual(dir.user_transport.base, target.user_transport.base)
466
568
self.assertTrue(shared_repo.has_revision('1'))
468
570
def test_sprout_bzrdir_repository_branch_both_under_shared(self):
470
572
shared_repo = self.make_repository('shared', shared=True)
471
573
except errors.IncompatibleFormat:
574
raise TestNotApplicable("format does not support shared "
576
if not shared_repo._format.supports_nesting_repositories:
577
raise TestNotApplicable("format does not support nesting "
473
579
tree = self.make_branch_and_tree('commit_tree')
474
580
self.build_tree(['commit_tree/foo'])
476
582
tree.commit('revision 1', rev_id='1')
477
583
tree.bzrdir.open_branch().generate_revision_history(
478
bzrlib.revision.NULL_REVISION)
584
_mod_revision.NULL_REVISION)
479
585
tree.set_parent_trees([])
480
586
tree.commit('revision 2', rev_id='2')
481
587
tree.branch.repository.copy_content_into(shared_repo)
491
597
shared_repo = self.make_repository('shared', shared=True)
492
598
except errors.IncompatibleFormat:
599
raise TestNotApplicable("format does not support shared "
601
if not shared_repo._format.supports_nesting_repositories:
602
raise TestNotApplicable("format does not support nesting "
494
604
tree = self.make_branch_and_tree('commit_tree')
495
605
self.build_tree(['commit_tree/foo'])
497
607
tree.commit('revision 1', rev_id='1')
498
608
tree.bzrdir.open_branch().generate_revision_history(
499
bzrlib.revision.NULL_REVISION)
609
_mod_revision.NULL_REVISION)
500
610
tree.set_parent_trees([])
501
611
tree.commit('revision 2', rev_id='2')
502
612
tree.branch.repository.copy_content_into(shared_repo)
619
733
referenced_tree.commit('1', rev_id='1', allow_pointless=True)
620
734
dir = self.make_bzrdir('source')
622
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
623
target_branch=referenced_tree.branch)
736
dir.set_branch_reference(referenced_tree.branch)
624
737
except errors.IncompatibleFormat:
625
# this is ok too, not all formats have to support references.
738
raise TestNotApplicable("format does not support branch "
627
740
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
629
742
shared_repo = self.make_repository('target', shared=True)
630
743
except errors.IncompatibleFormat:
744
raise TestNotApplicable("format does not support "
745
"shared repositories")
632
746
target = dir.sprout(self.get_url('target/child'))
633
747
self.assertNotEqual(dir.transport.base, target.transport.base)
634
748
# we want target to have a branch that is in-place.
645
759
referenced_tree.commit('1', rev_id='1', allow_pointless=True)
646
760
dir = self.make_bzrdir('source')
648
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
649
target_branch=referenced_tree.branch)
762
dir.set_branch_reference(referenced_tree.branch)
650
763
except errors.IncompatibleFormat:
651
764
# this is ok too, not all formats have to support references.
765
raise TestNotApplicable("format does not support "
653
767
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
655
769
shared_repo = self.make_repository('target', shared=True)
656
770
except errors.IncompatibleFormat:
771
raise TestNotApplicable("format does not support shared "
658
773
target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
659
774
self.assertNotEqual(dir.transport.base, target.transport.base)
660
775
# we want target to have a branch that is in-place.
759
877
# Create a tag for B2, and for an absent rev
760
878
source.tags.set_tag('tag-non-ancestry', 'rev-b2')
879
except errors.TagsNotSupported:
880
raise TestNotApplicable('Branch format does not support tags ')
761
882
source.tags.set_tag('tag-absent', 'absent-rev')
762
except errors.TagsNotSupported:
763
raise TestNotApplicable('Branch format does not support tags.')
883
except errors.GhostTagsNotSupported:
884
has_ghost_tag = False
887
source.get_config_stack().set('branch.fetch_tags', True)
764
888
# And ask sprout for C2
765
889
dir = source.bzrdir
766
890
target = dir.sprout(self.get_url('target'), revision_id='rev-c2')
767
891
# The tags are present
768
892
new_branch = target.open_branch()
770
{'tag-absent': 'absent-rev', 'tag-non-ancestry': 'rev-b2'},
771
new_branch.tags.get_tag_dict())
895
{'tag-absent': 'absent-rev', 'tag-non-ancestry': 'rev-b2'},
896
new_branch.tags.get_tag_dict())
899
{'tag-non-ancestry': 'rev-b2'},
900
new_branch.tags.get_tag_dict())
772
901
# And the revs for A2, B2 and C2's ancestries are present, but no
774
903
self.assertEqual(
950
1078
self.assertInitializeEx(t, create_prefix=True)
952
1080
def test_format_initialize_on_transport_ex_create_prefix_False(self):
953
if not self.bzrdir_format.is_supported():
954
# Not initializable - not a failure either.
1081
if not self.bzrdir_format.is_initializable():
1082
raise TestNotApplicable("format is not initializable")
956
1083
t = self.get_transport('missing/dir')
957
1084
self.assertRaises(errors.NoSuchFile, self.assertInitializeEx, t,
958
1085
create_prefix=False)
960
1087
def test_format_initialize_on_transport_ex_force_new_repo_True(self):
961
1088
t = self.get_transport('repo')
962
repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
1089
repo_fmt = controldir.format_registry.make_bzrdir('1.9')
963
1090
repo_name = repo_fmt.repository_format.network_name()
964
1091
repo = repo_fmt.initialize_on_transport_ex(t,
965
1092
repo_format_name=repo_name, shared_repo=True)[0]
966
1093
made_repo, control = self.assertInitializeEx(t.clone('branch'),
967
1094
force_new_repo=True, repo_format_name=repo_name)
969
# uninitialisable format
971
1095
self.assertNotEqual(repo.bzrdir.root_transport.base,
972
1096
made_repo.bzrdir.root_transport.base)
974
1098
def test_format_initialize_on_transport_ex_force_new_repo_False(self):
975
1099
t = self.get_transport('repo')
976
repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
1100
repo_fmt = controldir.format_registry.make_bzrdir('1.9')
977
1101
repo_name = repo_fmt.repository_format.network_name()
978
1102
repo = repo_fmt.initialize_on_transport_ex(t,
979
1103
repo_format_name=repo_name, shared_repo=True)[0]
980
1104
made_repo, control = self.assertInitializeEx(t.clone('branch'),
981
1105
force_new_repo=False, repo_format_name=repo_name)
983
# uninitialisable format
985
1106
if not control._format.fixed_components:
986
1107
self.assertEqual(repo.bzrdir.root_transport.base,
987
1108
made_repo.bzrdir.root_transport.base)
989
def test_format_initialize_on_transport_ex_stacked_on(self):
990
# trunk is a stackable format. Note that its in the same server area
991
# which is what launchpad does, but not sufficient to exercise the
993
trunk = self.make_branch('trunk', format='1.9')
994
t = self.get_transport('stacked')
995
old_fmt = bzrdir.format_registry.make_bzrdir('pack-0.92')
996
repo_name = old_fmt.repository_format.network_name()
997
# Should end up with a 1.9 format (stackable)
998
repo, control = self.assertInitializeEx(t, need_meta=True,
999
repo_format_name=repo_name, stacked_on='../trunk', stack_on_pwd=t.base)
1001
# uninitialisable format
1003
self.assertLength(1, repo._fallback_repositories)
1005
def test_format_initialize_on_transport_ex_default_stack_on(self):
1006
# When initialize_on_transport_ex uses a stacked-on branch because of
1007
# a stacking policy on the target, the location of the fallback
1008
# repository is the same as the external location of the stacked-on
1010
balloon = self.make_bzrdir('balloon')
1011
if isinstance(balloon._format, bzrdir.BzrDirMetaFormat1):
1012
stack_on = self.make_branch('stack-on', format='1.9')
1014
stack_on = self.make_branch('stack-on')
1015
config = self.make_bzrdir('.').get_config()
1017
config.set_default_stack_on('stack-on')
1018
except errors.BzrError:
1019
raise TestNotApplicable('Only relevant for stackable formats.')
1020
# Initialize a bzrdir subject to the policy.
1021
t = self.get_transport('stacked')
1022
repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
1023
repo_name = repo_fmt.repository_format.network_name()
1024
repo, control = self.assertInitializeEx(
1025
t, need_meta=True, repo_format_name=repo_name, stacked_on=None)
1026
# self.addCleanup(repo.unlock)
1028
# uninitialisable format
1030
# There's one fallback repo, with a public location.
1031
self.assertLength(1, repo._fallback_repositories)
1032
fallback_repo = repo._fallback_repositories[0]
1034
stack_on.base, fallback_repo.bzrdir.root_transport.base)
1035
# The bzrdir creates a branch in stacking-capable format.
1036
new_branch = control.create_branch()
1037
self.assertTrue(new_branch._format.supports_stacking())
1039
1110
def test_format_initialize_on_transport_ex_repo_fmt_name_None(self):
1040
1111
t = self.get_transport('dir')
1041
1112
repo, control = self.assertInitializeEx(t)
1044
1115
def test_format_initialize_on_transport_ex_repo_fmt_name_followed(self):
1045
1116
t = self.get_transport('dir')
1046
1117
# 1.6 is likely to never be default
1047
fmt = bzrdir.format_registry.make_bzrdir('1.6')
1118
fmt = controldir.format_registry.make_bzrdir('1.6')
1048
1119
repo_name = fmt.repository_format.network_name()
1049
1120
repo, control = self.assertInitializeEx(t, repo_format_name=repo_name)
1051
# uninitialisable format
1053
1121
if self.bzrdir_format.fixed_components:
1054
1122
# must stay with the all-in-one-format.
1055
1123
repo_name = self.bzrdir_format.network_name()
1056
1124
self.assertEqual(repo_name, repo._format.network_name())
1058
def assertInitializeEx(self, t, need_meta=False, **kwargs):
1126
def assertInitializeEx(self, t, **kwargs):
1059
1127
"""Execute initialize_on_transport_ex and check it succeeded correctly.
1061
1129
This involves checking that the disk objects were created, open with
1076
1144
self.assertTrue(repo.is_write_locked())
1077
1145
self.addCleanup(repo.unlock)
1078
1146
self.assertIsInstance(control, controldir.ControlDir)
1079
opened = bzrdir.BzrDir.open(t.base)
1147
opened = controldir.ControlDir.open(t.base)
1080
1148
expected_format = self.bzrdir_format
1081
if need_meta and expected_format.fixed_components:
1082
# Pre-metadir formats change when we are making something that
1083
# needs a metaformat, because clone is used for push.
1084
expected_format = bzrdir.BzrDirMetaFormat1()
1085
1149
if not isinstance(expected_format, RemoteBzrDirFormat):
1086
1150
self.assertEqual(control._format.network_name(),
1087
1151
expected_format.network_name())
1117
1181
# test the formats specific behaviour for no-content or similar dirs.
1118
1182
self.assertRaises(errors.NotBranchError,
1119
1183
self.bzrdir_format.open,
1120
transport.get_transport(self.get_readonly_url()))
1184
transport.get_transport_from_url(self.get_readonly_url()))
1122
1186
def test_create_branch(self):
1123
1187
# a bzrdir can construct a branch and repository for itself.
1124
if not self.bzrdir_format.is_supported():
1188
if not self.bzrdir_format.is_initializable():
1125
1189
# unsupported formats are not loopback testable
1126
1190
# because the default open will not open them and
1127
1191
# they may not be initializable.
1192
raise TestNotApplicable("format is not initializable")
1129
1193
t = self.get_transport()
1130
1194
made_control = self.bzrdir_format.initialize(t.base)
1131
1195
made_repo = made_control.create_repository()
1133
1197
self.assertIsInstance(made_branch, bzrlib.branch.Branch)
1134
1198
self.assertEqual(made_control, made_branch.bzrdir)
1200
def test_create_branch_append_revisions_only(self):
1201
# a bzrdir can construct a branch and repository for itself.
1202
if not self.bzrdir_format.is_initializable():
1203
# unsupported formats are not loopback testable
1204
# because the default open will not open them and
1205
# they may not be initializable.
1206
raise TestNotApplicable("format is not initializable")
1207
t = self.get_transport()
1208
made_control = self.bzrdir_format.initialize(t.base)
1209
made_repo = made_control.create_repository()
1211
made_branch = made_control.create_branch(
1212
append_revisions_only=True)
1213
except errors.UpgradeRequired:
1214
raise TestNotApplicable("format does not support "
1215
"append_revisions_only setting")
1216
self.assertIsInstance(made_branch, bzrlib.branch.Branch)
1217
self.assertEquals(True, made_branch.get_append_revisions_only())
1218
self.assertEqual(made_control, made_branch.bzrdir)
1136
1220
def test_open_branch(self):
1137
if not self.bzrdir_format.is_supported():
1221
if not self.bzrdir_format.is_initializable():
1138
1222
# unsupported formats are not loopback testable
1139
1223
# because the default open will not open them and
1140
1224
# they may not be initializable.
1225
raise TestNotApplicable("format is not initializable")
1142
1226
t = self.get_transport()
1143
1227
made_control = self.bzrdir_format.initialize(t.base)
1144
1228
made_repo = made_control.create_repository()
1169
1250
self.assertEquals([], made_control.list_branches())
1252
def test_get_branches(self):
1253
repo = self.make_repository('branch-1')
1254
target_branch = repo.bzrdir.create_branch()
1255
self.assertEqual([""], repo.bzrdir.get_branches().keys())
1171
1257
def test_create_repository(self):
1172
1258
# a bzrdir can construct a repository for itself.
1173
if not self.bzrdir_format.is_supported():
1259
if not self.bzrdir_format.is_initializable():
1174
1260
# unsupported formats are not loopback testable
1175
1261
# because the default open will not open them and
1176
1262
# they may not be initializable.
1263
raise TestNotApplicable("format is not initializable")
1178
1264
t = self.get_transport()
1179
1265
made_control = self.bzrdir_format.initialize(t.base)
1180
1266
made_repo = made_control.create_repository()
1197
1283
except errors.IncompatibleFormat:
1198
1284
# Old bzrdir formats don't support shared repositories
1199
1285
# and should raise IncompatibleFormat
1286
raise TestNotApplicable("format does not support shared "
1201
1288
self.assertTrue(made_repo.is_shared())
1203
1290
def test_create_repository_nonshared(self):
1204
1291
# a bzrdir can create a non-shared repository
1205
if not self.bzrdir_format.is_supported():
1292
if not self.bzrdir_format.is_initializable():
1206
1293
# unsupported formats are not loopback testable
1207
1294
# because the default open will not open them and
1208
1295
# they may not be initializable.
1296
raise TestNotApplicable("format is not initializable")
1210
1297
t = self.get_transport()
1211
1298
made_control = self.bzrdir_format.initialize(t.base)
1212
made_repo = made_control.create_repository(shared=False)
1300
made_repo = made_control.create_repository(shared=False)
1301
except errors.IncompatibleFormat:
1302
# Some control dir formats don't support non-shared repositories
1303
# and should raise IncompatibleFormat
1304
raise TestNotApplicable("format does not support shared "
1213
1306
self.assertFalse(made_repo.is_shared())
1215
1308
def test_open_repository(self):
1216
if not self.bzrdir_format.is_supported():
1309
if not self.bzrdir_format.is_initializable():
1217
1310
# unsupported formats are not loopback testable
1218
1311
# because the default open will not open them and
1219
1312
# they may not be initializable.
1313
raise TestNotApplicable("format is not initializable")
1221
1314
t = self.get_transport()
1222
1315
made_control = self.bzrdir_format.initialize(t.base)
1223
1316
made_repo = made_control.create_repository()
1280
1372
self.assertIsInstance(opened_tree, made_tree.__class__)
1281
1373
self.assertIsInstance(opened_tree._format, made_tree._format.__class__)
1375
def test_get_selected_branch(self):
1376
# The segment parameters are accessible from the root transport
1377
# if a URL with segment parameters is opened.
1378
if not self.bzrdir_format.is_initializable():
1379
raise TestNotApplicable("format is not initializable")
1380
t = self.get_transport()
1382
made_control = self.bzrdir_format.initialize(t.base)
1383
except (errors.NotLocalUrl, errors.UnsupportedOperation):
1384
raise TestSkipped("Can't initialize %r on transport %r"
1385
% (self.bzrdir_format, t))
1386
dir = controldir.ControlDir.open(t.base+",branch=foo")
1387
self.assertEquals({"branch": "foo"},
1388
dir.user_transport.get_segment_parameters())
1389
self.assertEquals("foo", dir._get_selected_branch())
1391
def test_get_selected_branch_none_selected(self):
1392
# _get_selected_branch defaults to None
1393
if not self.bzrdir_format.is_initializable():
1394
raise TestNotApplicable("format is not initializable")
1395
t = self.get_transport()
1397
made_control = self.bzrdir_format.initialize(t.base)
1398
except (errors.NotLocalUrl, errors.UnsupportedOperation):
1399
raise TestSkipped("Can't initialize %r on transport %r"
1400
% (self.bzrdir_format, t))
1401
dir = controldir.ControlDir.open(t.base)
1402
self.assertEqual(u"", dir._get_selected_branch())
1283
1404
def test_root_transport(self):
1284
1405
dir = self.make_bzrdir('.')
1285
1406
self.assertEqual(dir.root_transport.base,
1334
1461
found_repo.bzrdir.root_transport.base)
1336
1463
def test_find_repository_standalone_with_containing_shared_repository(self):
1337
# find repo inside a standalone repo inside a shared repo finds the standalone repo
1464
# find repo inside a standalone repo inside a shared repo finds the
1339
1467
containing_repo = self.make_repository('.', shared=True)
1340
1468
except errors.IncompatibleFormat:
1341
1469
# need a shared repository to test this.
1470
raise TestNotApplicable("requires support for shared "
1472
if not containing_repo._format.supports_nesting_repositories:
1473
raise TestNotApplicable("format does not support "
1474
"nesting repositories")
1343
1475
child_repo = self.make_repository('childrepo')
1344
opened_control = bzrdir.BzrDir.open(self.get_url('childrepo'))
1476
opened_control = controldir.ControlDir.open(self.get_url('childrepo'))
1345
1477
found_repo = opened_control.find_repository()
1346
1478
self.assertEqual(child_repo.bzrdir.root_transport.base,
1347
1479
found_repo.bzrdir.root_transport.base)
1352
1484
containing_repo = self.make_repository('.', shared=True)
1353
1485
except errors.IncompatibleFormat:
1354
1486
# need a shared repository to test this.
1487
raise TestNotApplicable("requires support for shared "
1489
if not containing_repo._format.supports_nesting_repositories:
1490
raise TestNotApplicable("requires support for nesting "
1356
1492
url = self.get_url('childrepo')
1357
1493
self.get_transport().mkdir('childrepo')
1358
1494
child_control = self.bzrdir_format.initialize(url)
1359
1495
child_repo = child_control.create_repository(shared=True)
1360
opened_control = bzrdir.BzrDir.open(self.get_url('childrepo'))
1496
opened_control = controldir.ControlDir.open(self.get_url('childrepo'))
1361
1497
found_repo = opened_control.find_repository()
1362
1498
self.assertEqual(child_repo.bzrdir.root_transport.base,
1363
1499
found_repo.bzrdir.root_transport.base)
1573
1713
except errors.BzrError, e:
1574
1714
if 'Cannot set config' in str(e):
1575
1715
self.assertFalse(
1576
isinstance(my_dir, (bzrdir.BzrDirMeta1, RemoteBzrDir)),
1716
isinstance(my_dir, (_mod_bzrdir.BzrDirMeta1, RemoteBzrDir)),
1577
1717
"%r should support configs" % my_dir)
1578
1718
raise TestNotApplicable(
1579
1719
'This BzrDir format does not support configs.')
1582
1722
self.assertEqual('http://example.com', config.get_default_stack_on())
1583
my_dir2 = bzrdir.BzrDir.open(self.get_url('.'))
1723
my_dir2 = controldir.ControlDir.open(self.get_url('.'))
1584
1724
config2 = my_dir2.get_config()
1585
1725
self.assertEqual('http://example.com', config2.get_default_stack_on())
1590
1730
def test_find_repository_no_repository(self):
1591
1731
# loopback test to check the current format fails to find a
1592
1732
# share repository correctly.
1593
if not self.bzrdir_format.is_supported():
1733
if not self.bzrdir_format.is_initializable():
1594
1734
# unsupported formats are not loopback testable
1595
1735
# because the default open will not open them and
1596
1736
# they may not be initializable.
1737
raise TestNotApplicable("format is not initializable")
1598
1738
# supported formats must be able to init and open
1599
1739
# - do the vfs initialisation over the basic vfs transport
1600
1740
# XXX: TODO this should become a 'bzrdirlocation' api call.
1601
1741
url = self.get_vfs_only_url('subdir')
1602
transport.get_transport(self.get_vfs_only_url()).mkdir('subdir')
1742
transport.get_transport_from_url(self.get_vfs_only_url()).mkdir('subdir')
1603
1743
made_control = self.bzrdir_format.initialize(self.get_url('subdir'))
1605
1745
repo = made_control.open_repository()