108
108
self.assertRaises(errors.UninitializableFormat,
109
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, '.')
111
122
def test_create_null_workingtree(self):
112
123
dir = self.make_bzrdir('dir1')
113
124
dir.create_repository()
148
159
bzrdir.create_branch()
149
160
bzrdir.open_branch()
162
def test_destroy_branch_no_branch(self):
163
branch = self.make_repository('branch')
164
bzrdir = branch.bzrdir
166
self.assertRaises(errors.NotBranchError, bzrdir.destroy_branch)
167
except (errors.UnsupportedOperation, errors.TransportNotPossible):
168
raise TestNotApplicable('Format does not support destroying branch')
151
170
def test_destroy_repository(self):
152
171
repo = self.make_repository('repository')
153
172
bzrdir = repo.bzrdir
415
434
"not support stacking")
416
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())
418
481
def test_get_branch_reference_on_reference(self):
419
482
"""get_branch_reference should return the right url."""
420
483
referenced_branch = self.make_branch('referenced')
421
484
dir = self.make_bzrdir('source')
423
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
424
target_branch=referenced_branch)
486
dir.set_branch_reference(referenced_branch)
425
487
except errors.IncompatibleFormat:
426
488
# this is ok too, not all formats have to support references.
427
489
raise TestNotApplicable("control directory does not "
652
714
referenced_branch = self.make_branch('referenced')
653
715
dir = self.make_bzrdir('source')
655
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
656
target_branch=referenced_branch)
717
dir.set_branch_reference(referenced_branch)
657
718
except errors.IncompatibleFormat:
658
719
raise TestNotApplicable("format does not support branch "
672
733
referenced_tree.commit('1', rev_id='1', allow_pointless=True)
673
734
dir = self.make_bzrdir('source')
675
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
676
target_branch=referenced_tree.branch)
736
dir.set_branch_reference(referenced_tree.branch)
677
737
except errors.IncompatibleFormat:
678
738
raise TestNotApplicable("format does not support branch "
699
759
referenced_tree.commit('1', rev_id='1', allow_pointless=True)
700
760
dir = self.make_bzrdir('source')
702
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
703
target_branch=referenced_tree.branch)
762
dir.set_branch_reference(referenced_tree.branch)
704
763
except errors.IncompatibleFormat:
705
764
# this is ok too, not all formats have to support references.
706
765
raise TestNotApplicable("format does not support "
851
910
referenced_branch = self.make_branch('referencced')
852
911
dir = self.make_bzrdir('source')
854
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
855
target_branch=referenced_branch)
913
dir.set_branch_reference(referenced_branch)
856
914
except errors.IncompatibleFormat:
857
915
# this is ok too, not all formats have to support references.
858
916
raise TestNotApplicable("format does not support "
878
936
referenced_branch = self.make_branch('referencced')
879
937
dir = self.make_bzrdir('source')
881
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
882
target_branch=referenced_branch)
939
dir.set_branch_reference(referenced_branch)
883
940
except errors.IncompatibleFormat:
884
941
# this is ok too, not all formats have to support references.
885
942
raise TestNotApplicable("format does not support "
1195
1252
def test_get_branches(self):
1196
1253
repo = self.make_repository('branch-1')
1197
1254
target_branch = repo.bzrdir.create_branch()
1198
self.assertEqual([None], repo.bzrdir.get_branches().keys())
1255
self.assertEqual([""], repo.bzrdir.get_branches().keys())
1200
1257
def test_create_repository(self):
1201
1258
# a bzrdir can construct a repository for itself.
1342
1399
raise TestSkipped("Can't initialize %r on transport %r"
1343
1400
% (self.bzrdir_format, t))
1344
1401
dir = bzrdir.BzrDir.open(t.base)
1345
self.assertIs(None, dir._get_selected_branch())
1402
self.assertEqual(u"", dir._get_selected_branch())
1347
1404
def test_root_transport(self):
1348
1405
dir = self.make_bzrdir('.')
1581
1638
master = self.make_branch('branch')
1582
1639
thisdir = self.make_bzrdir('this')
1584
bzrlib.branch.BranchReferenceFormat().initialize(
1585
thisdir, target_branch=master)
1641
thisdir.set_branch_reference(master)
1586
1642
except errors.IncompatibleFormat:
1587
1643
raise TestNotApplicable("format does not support "
1588
1644
"branch references")