~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
415
415
                "not support stacking")
416
416
        self.assertEqual(child.open_branch().get_stacked_on_url(), branch.base)
417
417
 
 
418
    def test_set_branch_reference(self):
 
419
        """set_branch_reference creates a branch reference"""
 
420
        referenced_branch = self.make_branch('referenced')
 
421
        dir = self.make_bzrdir('source')
 
422
        try:
 
423
            reference = dir.set_branch_reference(referenced_branch)
 
424
        except errors.IncompatibleFormat:
 
425
            # this is ok too, not all formats have to support references.
 
426
            raise TestNotApplicable("control directory does not "
 
427
                "support branch references")
 
428
        self.assertEqual(
 
429
            referenced_branch.bzrdir.root_transport.abspath('') + '/',
 
430
            dir.get_branch_reference())
 
431
 
 
432
    def test_set_branch_reference_on_existing_reference(self):
 
433
        """set_branch_reference creates a branch reference"""
 
434
        referenced_branch1 = self.make_branch('old-referenced')
 
435
        referenced_branch2 = self.make_branch('new-referenced')
 
436
        dir = self.make_bzrdir('source')
 
437
        try:
 
438
            reference = dir.set_branch_reference(referenced_branch1)
 
439
        except errors.IncompatibleFormat:
 
440
            # this is ok too, not all formats have to support references.
 
441
            raise TestNotApplicable("control directory does not "
 
442
                "support branch references")
 
443
        reference = dir.set_branch_reference(referenced_branch2)
 
444
        self.assertEqual(
 
445
            referenced_branch2.bzrdir.root_transport.abspath('') + '/',
 
446
            dir.get_branch_reference())
 
447
 
 
448
    def test_set_branch_reference_on_existing_branch(self):
 
449
        """set_branch_reference creates a branch reference"""
 
450
        referenced_branch = self.make_branch('referenced')
 
451
        dir = self.make_branch('source').bzrdir
 
452
        try:
 
453
            reference = dir.set_branch_reference(referenced_branch)
 
454
        except errors.IncompatibleFormat:
 
455
            # this is ok too, not all formats have to support references.
 
456
            raise TestNotApplicable("control directory does not "
 
457
                "support branch references")
 
458
        self.assertEqual(
 
459
            referenced_branch.bzrdir.root_transport.abspath('') + '/',
 
460
            dir.get_branch_reference())
 
461
 
418
462
    def test_get_branch_reference_on_reference(self):
419
463
        """get_branch_reference should return the right url."""
420
464
        referenced_branch = self.make_branch('referenced')
421
465
        dir = self.make_bzrdir('source')
422
466
        try:
423
 
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
424
 
                target_branch=referenced_branch)
 
467
            dir.set_branch_reference(referenced_branch)
425
468
        except errors.IncompatibleFormat:
426
469
            # this is ok too, not all formats have to support references.
427
470
            raise TestNotApplicable("control directory does not "
652
695
        referenced_branch = self.make_branch('referenced')
653
696
        dir = self.make_bzrdir('source')
654
697
        try:
655
 
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
656
 
                target_branch=referenced_branch)
 
698
            dir.set_branch_reference(referenced_branch)
657
699
        except errors.IncompatibleFormat:
658
700
            raise TestNotApplicable("format does not support branch "
659
701
                "references")
672
714
        referenced_tree.commit('1', rev_id='1', allow_pointless=True)
673
715
        dir = self.make_bzrdir('source')
674
716
        try:
675
 
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
676
 
                target_branch=referenced_tree.branch)
 
717
            dir.set_branch_reference(referenced_tree.branch)
677
718
        except errors.IncompatibleFormat:
678
719
            raise TestNotApplicable("format does not support branch "
679
720
                "references")
699
740
        referenced_tree.commit('1', rev_id='1', allow_pointless=True)
700
741
        dir = self.make_bzrdir('source')
701
742
        try:
702
 
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
703
 
                target_branch=referenced_tree.branch)
 
743
            dir.set_branch_reference(referenced_tree.branch)
704
744
        except errors.IncompatibleFormat:
705
745
            # this is ok too, not all formats have to support references.
706
746
            raise TestNotApplicable("format does not support "
851
891
        referenced_branch = self.make_branch('referencced')
852
892
        dir = self.make_bzrdir('source')
853
893
        try:
854
 
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
855
 
                target_branch=referenced_branch)
 
894
            dir.set_branch_reference(referenced_branch)
856
895
        except errors.IncompatibleFormat:
857
896
            # this is ok too, not all formats have to support references.
858
897
            raise TestNotApplicable("format does not support "
878
917
        referenced_branch = self.make_branch('referencced')
879
918
        dir = self.make_bzrdir('source')
880
919
        try:
881
 
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
882
 
                target_branch=referenced_branch)
 
920
            dir.set_branch_reference(referenced_branch)
883
921
        except errors.IncompatibleFormat:
884
922
            # this is ok too, not all formats have to support references.
885
923
            raise TestNotApplicable("format does not support "
1581
1619
        master = self.make_branch('branch')
1582
1620
        thisdir = self.make_bzrdir('this')
1583
1621
        try:
1584
 
            bzrlib.branch.BranchReferenceFormat().initialize(
1585
 
                thisdir, target_branch=master)
 
1622
            thisdir.set_branch_reference(master)
1586
1623
        except errors.IncompatibleFormat:
1587
1624
            raise TestNotApplicable("format does not support "
1588
1625
                "branch references")