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()
415
426
"not support stacking")
416
427
self.assertEqual(child.open_branch().get_stacked_on_url(), branch.base)
429
def test_set_branch_reference(self):
430
"""set_branch_reference creates a branch reference"""
431
referenced_branch = self.make_branch('referenced')
432
dir = self.make_bzrdir('source')
434
reference = dir.set_branch_reference(referenced_branch)
435
except errors.IncompatibleFormat:
436
# this is ok too, not all formats have to support references.
437
raise TestNotApplicable("control directory does not "
438
"support branch references")
440
referenced_branch.bzrdir.root_transport.abspath('') + '/',
441
dir.get_branch_reference())
443
def test_set_branch_reference_on_existing_reference(self):
444
"""set_branch_reference creates a branch reference"""
445
referenced_branch1 = self.make_branch('old-referenced')
446
referenced_branch2 = self.make_branch('new-referenced')
447
dir = self.make_bzrdir('source')
449
reference = dir.set_branch_reference(referenced_branch1)
450
except errors.IncompatibleFormat:
451
# this is ok too, not all formats have to support references.
452
raise TestNotApplicable("control directory does not "
453
"support branch references")
454
reference = dir.set_branch_reference(referenced_branch2)
456
referenced_branch2.bzrdir.root_transport.abspath('') + '/',
457
dir.get_branch_reference())
459
def test_set_branch_reference_on_existing_branch(self):
460
"""set_branch_reference creates a branch reference"""
461
referenced_branch = self.make_branch('referenced')
462
dir = self.make_branch('source').bzrdir
464
reference = dir.set_branch_reference(referenced_branch)
465
except errors.IncompatibleFormat:
466
# this is ok too, not all formats have to support references.
467
raise TestNotApplicable("control directory does not "
468
"support branch references")
470
referenced_branch.bzrdir.root_transport.abspath('') + '/',
471
dir.get_branch_reference())
418
473
def test_get_branch_reference_on_reference(self):
419
474
"""get_branch_reference should return the right url."""
420
475
referenced_branch = self.make_branch('referenced')
421
476
dir = self.make_bzrdir('source')
423
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
424
target_branch=referenced_branch)
478
dir.set_branch_reference(referenced_branch)
425
479
except errors.IncompatibleFormat:
426
480
# this is ok too, not all formats have to support references.
427
481
raise TestNotApplicable("control directory does not "
652
706
referenced_branch = self.make_branch('referenced')
653
707
dir = self.make_bzrdir('source')
655
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
656
target_branch=referenced_branch)
709
dir.set_branch_reference(referenced_branch)
657
710
except errors.IncompatibleFormat:
658
711
raise TestNotApplicable("format does not support branch "
672
725
referenced_tree.commit('1', rev_id='1', allow_pointless=True)
673
726
dir = self.make_bzrdir('source')
675
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
676
target_branch=referenced_tree.branch)
728
dir.set_branch_reference(referenced_tree.branch)
677
729
except errors.IncompatibleFormat:
678
730
raise TestNotApplicable("format does not support branch "
699
751
referenced_tree.commit('1', rev_id='1', allow_pointless=True)
700
752
dir = self.make_bzrdir('source')
702
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
703
target_branch=referenced_tree.branch)
754
dir.set_branch_reference(referenced_tree.branch)
704
755
except errors.IncompatibleFormat:
705
756
# this is ok too, not all formats have to support references.
706
757
raise TestNotApplicable("format does not support "
746
797
source.tags.set_tag('tag-a', 'rev-2')
747
798
except errors.TagsNotSupported:
748
799
raise TestNotApplicable('Branch format does not support tags.')
749
source.get_config().set_user_option('branch.fetch_tags', 'True')
800
source.get_config_stack().set('branch.fetch_tags', True)
750
801
# Now source has a tag not in its ancestry. Sprout its controldir.
751
802
dir = source.bzrdir
752
803
target = dir.sprout(self.get_url('target'))
851
902
referenced_branch = self.make_branch('referencced')
852
903
dir = self.make_bzrdir('source')
854
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
855
target_branch=referenced_branch)
905
dir.set_branch_reference(referenced_branch)
856
906
except errors.IncompatibleFormat:
857
907
# this is ok too, not all formats have to support references.
858
908
raise TestNotApplicable("format does not support "
878
928
referenced_branch = self.make_branch('referencced')
879
929
dir = self.make_bzrdir('source')
881
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
882
target_branch=referenced_branch)
931
dir.set_branch_reference(referenced_branch)
883
932
except errors.IncompatibleFormat:
884
933
# this is ok too, not all formats have to support references.
885
934
raise TestNotApplicable("format does not support "
1193
1242
self.assertEquals([], made_control.list_branches())
1244
def test_get_branches(self):
1245
repo = self.make_repository('branch-1')
1246
target_branch = repo.bzrdir.create_branch()
1247
self.assertEqual([""], repo.bzrdir.get_branches().keys())
1195
1249
def test_create_repository(self):
1196
1250
# a bzrdir can construct a repository for itself.
1197
1251
if not self.bzrdir_format.is_initializable():
1337
1391
raise TestSkipped("Can't initialize %r on transport %r"
1338
1392
% (self.bzrdir_format, t))
1339
1393
dir = bzrdir.BzrDir.open(t.base)
1340
self.assertIs(None, dir._get_selected_branch())
1394
self.assertEqual(u"", dir._get_selected_branch())
1342
1396
def test_root_transport(self):
1343
1397
dir = self.make_bzrdir('.')
1576
1630
master = self.make_branch('branch')
1577
1631
thisdir = self.make_bzrdir('this')
1579
bzrlib.branch.BranchReferenceFormat().initialize(
1580
thisdir, target_branch=master)
1633
thisdir.set_branch_reference(master)
1581
1634
except errors.IncompatibleFormat:
1582
1635
raise TestNotApplicable("format does not support "
1583
1636
"branch references")