185
202
shared_repo = self.make_repository('shared', shared=True)
186
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 "
188
209
# Make a branch, 'commit_tree', and working tree outside of the shared
189
210
# repository, and commit some revisions to it.
190
211
tree = self.make_branch_and_tree('commit_tree')
191
212
self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
193
214
tree.commit('revision 1', rev_id='1')
194
tree.bzrdir.open_branch().set_revision_history([])
215
tree.bzrdir.open_branch().generate_revision_history(
216
bzrlib.revision.NULL_REVISION)
195
217
tree.set_parent_trees([])
196
218
tree.commit('revision 2', rev_id='2')
197
219
# Copy the content (i.e. revisions) from the 'commit_tree' branch's
286
314
tree.branch.repository.copy_content_into(source.repository)
287
315
tree.branch.copy_content_into(source)
289
self.make_repository('target', shared=True)
317
shared_repo = self.make_repository('target', shared=True)
290
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 "
292
324
dir = source.bzrdir
293
325
target = dir.clone(self.get_url('target/child'))
294
326
self.assertNotEqual(dir.transport.base, target.transport.base)
295
327
self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
296
self.assertEqual(source.revision_history(),
297
target.open_branch().revision_history())
328
self.assertEqual(source.last_revision(),
329
target.open_branch().last_revision())
299
331
def test_clone_bzrdir_branch_revision(self):
300
332
# test for revision limiting, [smoke test, not corner case checks].
363
395
repo.set_make_working_trees(False)
364
396
self.assertFalse(repo.make_working_trees())
367
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')
369
404
self.assertRaises(errors.NoWorkingTree, a_dir.open_workingtree)
371
406
def test_clone_respects_stacked(self):
372
407
branch = self.make_branch('parent')
373
408
child_transport = self.get_transport('child')
374
child = branch.bzrdir.clone_on_transport(child_transport,
375
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")
376
416
self.assertEqual(child.open_branch().get_stacked_on_url(), branch.base)
378
418
def test_get_branch_reference_on_reference(self):
454
500
shared_repo = self.make_repository('target', shared=True)
455
501
except errors.IncompatibleFormat:
502
raise TestNotApplicable("format does not support "
503
"shared repositories")
457
504
target = dir.sprout(self.get_url('target/child'))
458
self.assertNotEqual(dir.transport.base, target.transport.base)
505
self.assertNotEqual(dir.user_transport.base, target.user_transport.base)
459
506
self.assertTrue(shared_repo.has_revision('1'))
461
508
def test_sprout_bzrdir_repository_branch_both_under_shared(self):
463
510
shared_repo = self.make_repository('shared', shared=True)
464
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 "
466
517
tree = self.make_branch_and_tree('commit_tree')
467
518
self.build_tree(['commit_tree/foo'])
469
520
tree.commit('revision 1', rev_id='1')
470
tree.bzrdir.open_branch().set_revision_history([])
521
tree.bzrdir.open_branch().generate_revision_history(
522
bzrlib.revision.NULL_REVISION)
471
523
tree.set_parent_trees([])
472
524
tree.commit('revision 2', rev_id='2')
473
525
tree.branch.repository.copy_content_into(shared_repo)
667
737
target = dir.sprout(self.get_url('target'), revision_id='1')
668
738
self.assertEqual('1', target.open_branch().last_revision())
740
def test_sprout_bzrdir_branch_with_tags(self):
741
# when sprouting a branch all revisions named in the tags are copied
743
builder = self.make_branch_builder('source')
744
source = fixtures.build_branch_with_non_ancestral_rev(builder)
746
source.tags.set_tag('tag-a', 'rev-2')
747
except errors.TagsNotSupported:
748
raise TestNotApplicable('Branch format does not support tags.')
749
source.get_config().set_user_option('branch.fetch_tags', 'True')
750
# Now source has a tag not in its ancestry. Sprout its controldir.
752
target = dir.sprout(self.get_url('target'))
753
# The tag is present, and so is its revision.
754
new_branch = target.open_branch()
755
self.assertEqual('rev-2', new_branch.tags.lookup_tag('tag-a'))
756
new_branch.repository.get_revision('rev-2')
758
def test_sprout_bzrdir_branch_with_absent_tag(self):
759
# tags referencing absent revisions are copied (and those absent
760
# revisions do not prevent the sprout.)
761
builder = self.make_branch_builder('source')
762
builder.build_commit(message="Rev 1", rev_id='rev-1')
763
source = builder.get_branch()
765
source.tags.set_tag('tag-a', 'missing-rev')
766
except (errors.TagsNotSupported, errors.GhostTagsNotSupported):
767
raise TestNotApplicable('Branch format does not support tags '
768
'or tags referencing ghost revisions.')
769
# Now source has a tag pointing to an absent revision. Sprout its
772
target = dir.sprout(self.get_url('target'))
773
# The tag is present in the target
774
new_branch = target.open_branch()
775
self.assertEqual('missing-rev', new_branch.tags.lookup_tag('tag-a'))
777
def test_sprout_bzrdir_passing_source_branch_with_absent_tag(self):
778
# tags referencing absent revisions are copied (and those absent
779
# revisions do not prevent the sprout.)
780
builder = self.make_branch_builder('source')
781
builder.build_commit(message="Rev 1", rev_id='rev-1')
782
source = builder.get_branch()
784
source.tags.set_tag('tag-a', 'missing-rev')
785
except (errors.TagsNotSupported, errors.GhostTagsNotSupported):
786
raise TestNotApplicable('Branch format does not support tags '
787
'or tags referencing missing revisions.')
788
# Now source has a tag pointing to an absent revision. Sprout its
791
target = dir.sprout(self.get_url('target'), source_branch=source)
792
# The tag is present in the target
793
new_branch = target.open_branch()
794
self.assertEqual('missing-rev', new_branch.tags.lookup_tag('tag-a'))
796
def test_sprout_bzrdir_passing_rev_not_source_branch_copies_tags(self):
797
# dir.sprout(..., revision_id='rev1') copies rev1, and all the tags of
798
# the branch at that bzrdir, the ancestry of all of those, but no other
799
# revs (not even the tip of the source branch).
800
builder = self.make_branch_builder('source')
801
builder.build_commit(message="Base", rev_id='base-rev')
802
# Make three parallel lines of ancestry off this base.
803
source = builder.get_branch()
804
builder.build_commit(message="Rev A1", rev_id='rev-a1')
805
builder.build_commit(message="Rev A2", rev_id='rev-a2')
806
builder.build_commit(message="Rev A3", rev_id='rev-a3')
807
source.set_last_revision_info(1, 'base-rev')
808
builder.build_commit(message="Rev B1", rev_id='rev-b1')
809
builder.build_commit(message="Rev B2", rev_id='rev-b2')
810
builder.build_commit(message="Rev B3", rev_id='rev-b3')
811
source.set_last_revision_info(1, 'base-rev')
812
builder.build_commit(message="Rev C1", rev_id='rev-c1')
813
builder.build_commit(message="Rev C2", rev_id='rev-c2')
814
builder.build_commit(message="Rev C3", rev_id='rev-c3')
815
# Set the branch tip to A2
816
source.set_last_revision_info(3, 'rev-a2')
818
# Create a tag for B2, and for an absent rev
819
source.tags.set_tag('tag-non-ancestry', 'rev-b2')
820
except errors.TagsNotSupported:
821
raise TestNotApplicable('Branch format does not support tags ')
823
source.tags.set_tag('tag-absent', 'absent-rev')
824
except errors.GhostTagsNotSupported:
825
has_ghost_tag = False
828
source.get_config().set_user_option('branch.fetch_tags', 'True')
829
# And ask sprout for C2
831
target = dir.sprout(self.get_url('target'), revision_id='rev-c2')
832
# The tags are present
833
new_branch = target.open_branch()
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())
842
# And the revs for A2, B2 and C2's ancestries are present, but no
845
['base-rev', 'rev-b1', 'rev-b2', 'rev-c1', 'rev-c2'],
846
sorted(new_branch.repository.all_revision_ids()))
670
848
def test_sprout_bzrdir_tree_branch_reference(self):
671
849
# sprouting should create a repository if needed and a sprouted branch.
672
850
# the tree state should not be copied.
870
1046
repo_format_name=repo_name, shared_repo=True)[0]
871
1047
made_repo, control = self.assertInitializeEx(t.clone('branch'),
872
1048
force_new_repo=False, repo_format_name=repo_name)
874
# uninitialisable format
876
if not isinstance(control._format, (bzrdir.BzrDirFormat5,
877
bzrdir.BzrDirFormat6,)):
1049
if not control._format.fixed_components:
878
1050
self.assertEqual(repo.bzrdir.root_transport.base,
879
1051
made_repo.bzrdir.root_transport.base)
881
def test_format_initialize_on_transport_ex_stacked_on(self):
882
# trunk is a stackable format. Note that its in the same server area
883
# which is what launchpad does, but not sufficient to exercise the
885
trunk = self.make_branch('trunk', format='1.9')
886
t = self.get_transport('stacked')
887
old_fmt = bzrdir.format_registry.make_bzrdir('pack-0.92')
888
repo_name = old_fmt.repository_format.network_name()
889
# Should end up with a 1.9 format (stackable)
890
repo, control = self.assertInitializeEx(t, need_meta=True,
891
repo_format_name=repo_name, stacked_on='../trunk', stack_on_pwd=t.base)
893
# uninitialisable format
895
self.assertLength(1, repo._fallback_repositories)
897
def test_format_initialize_on_transport_ex_default_stack_on(self):
898
# When initialize_on_transport_ex uses a stacked-on branch because of
899
# a stacking policy on the target, the location of the fallback
900
# repository is the same as the external location of the stacked-on
902
balloon = self.make_bzrdir('balloon')
903
if isinstance(balloon._format, bzrdir.BzrDirMetaFormat1):
904
stack_on = self.make_branch('stack-on', format='1.9')
906
stack_on = self.make_branch('stack-on')
907
config = self.make_bzrdir('.').get_config()
909
config.set_default_stack_on('stack-on')
910
except errors.BzrError:
911
raise TestNotApplicable('Only relevant for stackable formats.')
912
# Initialize a bzrdir subject to the policy.
913
t = self.get_transport('stacked')
914
repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
915
repo_name = repo_fmt.repository_format.network_name()
916
repo, control = self.assertInitializeEx(
917
t, need_meta=True, repo_format_name=repo_name, stacked_on=None)
918
# self.addCleanup(repo.unlock)
920
# uninitialisable format
922
# There's one fallback repo, with a public location.
923
self.assertLength(1, repo._fallback_repositories)
924
fallback_repo = repo._fallback_repositories[0]
926
stack_on.base, fallback_repo.bzrdir.root_transport.base)
927
# The bzrdir creates a branch in stacking-capable format.
928
new_branch = control.create_branch()
929
self.assertTrue(new_branch._format.supports_stacking())
931
1053
def test_format_initialize_on_transport_ex_repo_fmt_name_None(self):
932
1054
t = self.get_transport('dir')
933
1055
repo, control = self.assertInitializeEx(t)
959
1077
initialize_on_transport_ex.
960
1078
:return: the resulting repo, control dir tuple.
962
if not self.bzrdir_format.is_supported():
963
# Not initializable - not a failure either.
1080
if not self.bzrdir_format.is_initializable():
1081
raise TestNotApplicable("control dir format is not "
965
1083
repo, control, require_stacking, repo_policy = \
966
1084
self.bzrdir_format.initialize_on_transport_ex(t, **kwargs)
967
1085
if repo is not None:
968
1086
# Repositories are open write-locked
969
1087
self.assertTrue(repo.is_write_locked())
970
1088
self.addCleanup(repo.unlock)
971
self.assertIsInstance(control, bzrdir.BzrDir)
1089
self.assertIsInstance(control, controldir.ControlDir)
972
1090
opened = bzrdir.BzrDir.open(t.base)
973
1091
expected_format = self.bzrdir_format
974
if isinstance(expected_format, bzrdir.RemoteBzrDirFormat):
975
# Current RemoteBzrDirFormat's do not reliably get network_name
976
# set, so we skip a number of tests for RemoteBzrDirFormat's.
977
self.assertIsInstance(control, RemoteBzrDir)
979
if need_meta and isinstance(expected_format, (bzrdir.BzrDirFormat5,
980
bzrdir.BzrDirFormat6)):
981
# Pre-metadir formats change when we are making something that
982
# needs a metaformat, because clone is used for push.
983
expected_format = bzrdir.BzrDirMetaFormat1()
1092
if not isinstance(expected_format, RemoteBzrDirFormat):
984
1093
self.assertEqual(control._format.network_name(),
985
1094
expected_format.network_name())
986
1095
self.assertEqual(control._format.network_name(),
1015
1124
# test the formats specific behaviour for no-content or similar dirs.
1016
1125
self.assertRaises(errors.NotBranchError,
1017
1126
self.bzrdir_format.open,
1018
transport.get_transport(self.get_readonly_url()))
1127
transport.get_transport_from_url(self.get_readonly_url()))
1020
1129
def test_create_branch(self):
1021
1130
# a bzrdir can construct a branch and repository for itself.
1022
if not self.bzrdir_format.is_supported():
1131
if not self.bzrdir_format.is_initializable():
1023
1132
# unsupported formats are not loopback testable
1024
1133
# because the default open will not open them and
1025
1134
# they may not be initializable.
1027
t = transport.get_transport(self.get_url())
1135
raise TestNotApplicable("format is not initializable")
1136
t = self.get_transport()
1028
1137
made_control = self.bzrdir_format.initialize(t.base)
1029
1138
made_repo = made_control.create_repository()
1030
1139
made_branch = made_control.create_branch()
1031
self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
1140
self.assertIsInstance(made_branch, bzrlib.branch.Branch)
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())
1032
1161
self.assertEqual(made_control, made_branch.bzrdir)
1034
1163
def test_open_branch(self):
1035
if not self.bzrdir_format.is_supported():
1164
if not self.bzrdir_format.is_initializable():
1036
1165
# unsupported formats are not loopback testable
1037
1166
# because the default open will not open them and
1038
1167
# they may not be initializable.
1040
t = transport.get_transport(self.get_url())
1168
raise TestNotApplicable("format is not initializable")
1169
t = self.get_transport()
1041
1170
made_control = self.bzrdir_format.initialize(t.base)
1042
1171
made_repo = made_control.create_repository()
1043
1172
made_branch = made_control.create_branch()
1044
1173
opened_branch = made_control.open_branch()
1045
1174
self.assertEqual(made_control, opened_branch.bzrdir)
1046
self.failUnless(isinstance(opened_branch, made_branch.__class__))
1047
self.failUnless(isinstance(opened_branch._format, made_branch._format.__class__))
1175
self.assertIsInstance(opened_branch, made_branch.__class__)
1176
self.assertIsInstance(opened_branch._format, made_branch._format.__class__)
1049
1178
def test_list_branches(self):
1050
if not self.bzrdir_format.is_supported():
1051
# unsupported formats are not loopback testable
1052
# because the default open will not open them and
1053
# they may not be initializable.
1055
t = transport.get_transport(self.get_url())
1179
if not self.bzrdir_format.is_initializable():
1180
raise TestNotApplicable("format is not initializable")
1181
t = self.get_transport()
1056
1182
made_control = self.bzrdir_format.initialize(t.base)
1057
1183
made_repo = made_control.create_repository()
1058
1184
made_branch = made_control.create_branch()
1083
1214
def test_create_repository_shared(self):
1084
1215
# a bzrdir can create a shared repository or
1085
1216
# fail appropriately
1086
if not self.bzrdir_format.is_supported():
1217
if not self.bzrdir_format.is_initializable():
1087
1218
# unsupported formats are not loopback testable
1088
1219
# because the default open will not open them and
1089
1220
# they may not be initializable.
1091
t = transport.get_transport(self.get_url())
1221
raise TestNotApplicable("format is not initializable")
1222
t = self.get_transport()
1092
1223
made_control = self.bzrdir_format.initialize(t.base)
1094
1225
made_repo = made_control.create_repository(shared=True)
1095
1226
except errors.IncompatibleFormat:
1096
1227
# Old bzrdir formats don't support shared repositories
1097
1228
# and should raise IncompatibleFormat
1229
raise TestNotApplicable("format does not support shared "
1099
1231
self.assertTrue(made_repo.is_shared())
1101
1233
def test_create_repository_nonshared(self):
1102
1234
# a bzrdir can create a non-shared repository
1103
if not self.bzrdir_format.is_supported():
1235
if not self.bzrdir_format.is_initializable():
1104
1236
# unsupported formats are not loopback testable
1105
1237
# because the default open will not open them and
1106
1238
# they may not be initializable.
1108
t = transport.get_transport(self.get_url())
1239
raise TestNotApplicable("format is not initializable")
1240
t = self.get_transport()
1109
1241
made_control = self.bzrdir_format.initialize(t.base)
1110
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 "
1111
1249
self.assertFalse(made_repo.is_shared())
1113
1251
def test_open_repository(self):
1114
if not self.bzrdir_format.is_supported():
1252
if not self.bzrdir_format.is_initializable():
1115
1253
# unsupported formats are not loopback testable
1116
1254
# because the default open will not open them and
1117
1255
# they may not be initializable.
1119
t = transport.get_transport(self.get_url())
1256
raise TestNotApplicable("format is not initializable")
1257
t = self.get_transport()
1120
1258
made_control = self.bzrdir_format.initialize(t.base)
1121
1259
made_repo = made_control.create_repository()
1122
1260
opened_repo = made_control.open_repository()
1123
1261
self.assertEqual(made_control, opened_repo.bzrdir)
1124
self.failUnless(isinstance(opened_repo, made_repo.__class__))
1125
self.failUnless(isinstance(opened_repo._format, made_repo._format.__class__))
1262
self.assertIsInstance(opened_repo, made_repo.__class__)
1263
self.assertIsInstance(opened_repo._format, made_repo._format.__class__)
1127
1265
def test_create_workingtree(self):
1128
1266
# a bzrdir can construct a working tree for itself.
1129
if not self.bzrdir_format.is_supported():
1267
if not self.bzrdir_format.is_initializable():
1130
1268
# unsupported formats are not loopback testable
1131
1269
# because the default open will not open them and
1132
1270
# they may not be initializable.
1271
raise TestNotApplicable("format is not initializable")
1134
1272
t = self.get_transport()
1135
1273
made_control = self.bzrdir_format.initialize(t.base)
1136
1274
made_repo = made_control.create_repository()
1137
1275
made_branch = made_control.create_branch()
1138
1276
made_tree = self.createWorkingTreeOrSkip(made_control)
1139
self.failUnless(isinstance(made_tree, workingtree.WorkingTree))
1277
self.assertIsInstance(made_tree, workingtree.WorkingTree)
1140
1278
self.assertEqual(made_control, made_tree.bzrdir)
1142
1280
def test_create_workingtree_revision(self):
1143
1281
# a bzrdir can construct a working tree for itself @ a specific revision.
1282
if not self.bzrdir_format.is_initializable():
1283
raise TestNotApplicable("format is not initializable")
1144
1284
t = self.get_transport()
1145
1285
source = self.make_branch_and_tree('source')
1146
1286
source.commit('a', rev_id='a', allow_pointless=True)
1175
1312
% (self.bzrdir_format, t))
1176
1313
opened_tree = made_control.open_workingtree()
1177
1314
self.assertEqual(made_control, opened_tree.bzrdir)
1178
self.failUnless(isinstance(opened_tree, made_tree.__class__))
1179
self.failUnless(isinstance(opened_tree._format, made_tree._format.__class__))
1181
def test_get_branch_transport(self):
1182
dir = self.make_bzrdir('.')
1183
# without a format, get_branch_transport gives use a transport
1184
# which -may- point to an existing dir.
1185
self.assertTrue(isinstance(dir.get_branch_transport(None),
1186
transport.Transport))
1187
# with a given format, either the bzr dir supports identifiable
1188
# branches, or it supports anonymous branch formats, but not both.
1189
anonymous_format = bzrlib.branch.BzrBranchFormat4()
1190
identifiable_format = bzrlib.branch.BzrBranchFormat5()
1192
found_transport = dir.get_branch_transport(anonymous_format)
1193
self.assertRaises(errors.IncompatibleFormat,
1194
dir.get_branch_transport,
1195
identifiable_format)
1196
except errors.IncompatibleFormat:
1197
found_transport = dir.get_branch_transport(identifiable_format)
1198
self.assertTrue(isinstance(found_transport, transport.Transport))
1199
# and the dir which has been initialized for us must exist.
1200
found_transport.list_dir('.')
1202
def test_get_repository_transport(self):
1203
dir = self.make_bzrdir('.')
1204
# without a format, get_repository_transport gives use a transport
1205
# which -may- point to an existing dir.
1206
self.assertTrue(isinstance(dir.get_repository_transport(None),
1207
transport.Transport))
1208
# with a given format, either the bzr dir supports identifiable
1209
# repositories, or it supports anonymous repository formats, but not both.
1210
anonymous_format = weaverepo.RepositoryFormat6()
1211
identifiable_format = weaverepo.RepositoryFormat7()
1213
found_transport = dir.get_repository_transport(anonymous_format)
1214
self.assertRaises(errors.IncompatibleFormat,
1215
dir.get_repository_transport,
1216
identifiable_format)
1217
except errors.IncompatibleFormat:
1218
found_transport = dir.get_repository_transport(identifiable_format)
1219
self.assertTrue(isinstance(found_transport, transport.Transport))
1220
# and the dir which has been initialized for us must exist.
1221
found_transport.list_dir('.')
1223
def test_get_workingtree_transport(self):
1224
dir = self.make_bzrdir('.')
1225
# without a format, get_workingtree_transport gives use a transport
1226
# which -may- point to an existing dir.
1227
self.assertTrue(isinstance(dir.get_workingtree_transport(None),
1228
transport.Transport))
1229
# with a given format, either the bzr dir supports identifiable
1230
# trees, or it supports anonymous tree formats, but not both.
1231
anonymous_format = workingtree.WorkingTreeFormat2()
1232
identifiable_format = workingtree.WorkingTreeFormat3()
1234
found_transport = dir.get_workingtree_transport(anonymous_format)
1235
self.assertRaises(errors.IncompatibleFormat,
1236
dir.get_workingtree_transport,
1237
identifiable_format)
1238
except errors.IncompatibleFormat:
1239
found_transport = dir.get_workingtree_transport(identifiable_format)
1240
self.assertTrue(isinstance(found_transport, transport.Transport))
1241
# and the dir which has been initialized for us must exist.
1242
found_transport.list_dir('.')
1315
self.assertIsInstance(opened_tree, made_tree.__class__)
1316
self.assertIsInstance(opened_tree._format, made_tree._format.__class__)
1318
def test_get_selected_branch(self):
1319
# The segment parameters are accessible from the root transport
1320
# if a URL with segment parameters is opened.
1321
if not self.bzrdir_format.is_initializable():
1322
raise TestNotApplicable("format is not initializable")
1323
t = self.get_transport()
1325
made_control = self.bzrdir_format.initialize(t.base)
1326
except (errors.NotLocalUrl, errors.UnsupportedOperation):
1327
raise TestSkipped("Can't initialize %r on transport %r"
1328
% (self.bzrdir_format, t))
1329
dir = bzrdir.BzrDir.open(t.base+",branch=foo")
1330
self.assertEquals({"branch": "foo"},
1331
dir.user_transport.get_segment_parameters())
1332
self.assertEquals("foo", dir._get_selected_branch())
1334
def test_get_selected_branch_none_selected(self):
1335
# _get_selected_branch defaults to None
1336
if not self.bzrdir_format.is_initializable():
1337
raise TestNotApplicable("format is not initializable")
1338
t = self.get_transport()
1340
made_control = self.bzrdir_format.initialize(t.base)
1341
except (errors.NotLocalUrl, errors.UnsupportedOperation):
1342
raise TestSkipped("Can't initialize %r on transport %r"
1343
% (self.bzrdir_format, t))
1344
dir = bzrdir.BzrDir.open(t.base)
1345
self.assertIs(None, dir._get_selected_branch())
1244
1347
def test_root_transport(self):
1245
1348
dir = self.make_bzrdir('.')
1246
1349
self.assertEqual(dir.root_transport.base,
1247
transport.get_transport(self.get_url('.')).base)
1350
self.get_transport().base)
1249
1352
def test_find_repository_no_repo_under_standalone_branch(self):
1250
1353
# finding a repo stops at standalone branches even if there is a