~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_controldir/test_controldir.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-23 19:08:05 UTC
  • mfrom: (6437.3.20 2.5)
  • mto: This revision was merged to the branch mainline in revision 6450.
  • Revision ID: jelmer@samba.org-20120123190805-hlcuihkt2dep44cw
merge bzr 2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
        self.assertRaises(errors.UninitializableFormat,
109
109
            self.bzrdir_format.initialize, t.base)
110
110
 
 
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, '.')
 
121
 
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)
417
428
 
 
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')
 
433
        try:
 
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")
 
439
        self.assertEqual(
 
440
            referenced_branch.bzrdir.root_transport.abspath('') + '/',
 
441
            dir.get_branch_reference())
 
442
 
 
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')
 
448
        try:
 
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)
 
455
        self.assertEqual(
 
456
            referenced_branch2.bzrdir.root_transport.abspath('') + '/',
 
457
            dir.get_branch_reference())
 
458
 
 
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
 
463
        try:
 
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")
 
469
        self.assertEqual(
 
470
            referenced_branch.bzrdir.root_transport.abspath('') + '/',
 
471
            dir.get_branch_reference())
 
472
 
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')
422
477
        try:
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')
654
708
        try:
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 "
659
712
                "references")
672
725
        referenced_tree.commit('1', rev_id='1', allow_pointless=True)
673
726
        dir = self.make_bzrdir('source')
674
727
        try:
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 "
679
731
                "references")
699
751
        referenced_tree.commit('1', rev_id='1', allow_pointless=True)
700
752
        dir = self.make_bzrdir('source')
701
753
        try:
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'))
825
876
            has_ghost_tag = False
826
877
        else:
827
878
            has_ghost_tag = True
828
 
        source.get_config().set_user_option('branch.fetch_tags', 'True')
 
879
        source.get_config_stack().set('branch.fetch_tags', True)
829
880
        # And ask sprout for C2
830
881
        dir = source.bzrdir
831
882
        target = dir.sprout(self.get_url('target'), revision_id='rev-c2')
851
902
        referenced_branch = self.make_branch('referencced')
852
903
        dir = self.make_bzrdir('source')
853
904
        try:
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')
880
930
        try:
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 "
1192
1241
        else:
1193
1242
            self.assertEquals([], made_control.list_branches())
1194
1243
 
 
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())
 
1248
 
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())
1341
1395
 
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')
1578
1632
        try:
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")