~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2012-01-23 15:31:35 UTC
  • mfrom: (6443.1.1 bzr.dev)
  • Revision ID: pqm@pqm.ubuntu.com-20120123153135-8v3r3z1lx055vmpl
(jelmer) Merge the 2.5 series branch. (Jelmer Vernooij)

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 "
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 "
1581
1630
        master = self.make_branch('branch')
1582
1631
        thisdir = self.make_bzrdir('this')
1583
1632
        try:
1584
 
            bzrlib.branch.BranchReferenceFormat().initialize(
1585
 
                thisdir, target_branch=master)
 
1633
            thisdir.set_branch_reference(master)
1586
1634
        except errors.IncompatibleFormat:
1587
1635
            raise TestNotApplicable("format does not support "
1588
1636
                "branch references")