/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_branch.py

  • Committer: Andrew Bennetts
  • Date: 2011-04-08 03:31:54 UTC
  • mfrom: (5766 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5767.
  • Revision ID: andrew.bennetts@canonical.com-20110408033154-la08nghd4391sw5m
Merge latest lp:bzr, move our new release notes entries to the current release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    gpg,
26
26
    merge,
27
27
    urlutils,
28
 
    transactions,
29
28
    transport,
30
29
    remote,
31
30
    repository,
32
31
    revision,
33
32
    tests,
34
33
    )
35
 
from bzrlib.symbol_versioning import deprecated_in
36
34
from bzrlib.tests import (
37
 
    http_server,
38
35
    per_branch,
39
36
    )
40
37
from bzrlib.tests.http_server import HttpServer
736
733
        except errors.UpgradeRequired:
737
734
            raise tests.TestNotApplicable('Format does not support binding')
738
735
 
 
736
    def test_unbind_clears_cached_master_branch(self):
 
737
        """b.unbind clears any cached value of b.get_master_branch."""
 
738
        master = self.make_branch('master')
 
739
        branch = self.make_branch('branch')
 
740
        try:
 
741
            branch.bind(master)
 
742
        except errors.UpgradeRequired:
 
743
            raise tests.TestNotApplicable('Format does not support binding')
 
744
        self.addCleanup(branch.lock_write().unlock)
 
745
        self.assertNotEqual(None, branch.get_master_branch())
 
746
        branch.unbind()
 
747
        self.assertEqual(None, branch.get_master_branch())
 
748
 
 
749
    def test_unlocked_does_not_cache_master_branch(self):
 
750
        """Unlocked branches do not cache the result of get_master_branch."""
 
751
        master = self.make_branch('master')
 
752
        branch1 = self.make_branch('branch')
 
753
        try:
 
754
            branch1.bind(master)
 
755
        except errors.UpgradeRequired:
 
756
            raise tests.TestNotApplicable('Format does not support binding')
 
757
        # Open branch1 again
 
758
        branch2 = branch1.bzrdir.open_branch()
 
759
        self.assertNotEqual(None, branch1.get_master_branch())
 
760
        # Unbind the branch via branch2.  branch1 isn't locked so will
 
761
        # immediately return the new value for get_master_branch.
 
762
        branch2.unbind()
 
763
        self.assertEqual(None, branch1.get_master_branch())
 
764
 
 
765
    def test_bind_clears_cached_master_branch(self):
 
766
        """b.bind clears any cached value of b.get_master_branch."""
 
767
        master1 = self.make_branch('master1')
 
768
        master2 = self.make_branch('master2')
 
769
        branch = self.make_branch('branch')
 
770
        try:
 
771
            branch.bind(master1)
 
772
        except errors.UpgradeRequired:
 
773
            raise tests.TestNotApplicable('Format does not support binding')
 
774
        self.addCleanup(branch.lock_write().unlock)
 
775
        self.assertNotEqual(None, branch.get_master_branch())
 
776
        branch.bind(master2)
 
777
        self.assertEqual('.', urlutils.relative_url(self.get_url('master2'),
 
778
                branch.get_master_branch().base))
 
779
 
 
780
    def test_set_bound_location_clears_cached_master_branch(self):
 
781
        """b.set_bound_location clears any cached value of b.get_master_branch.
 
782
        """
 
783
        master1 = self.make_branch('master1')
 
784
        master2 = self.make_branch('master2')
 
785
        branch = self.make_branch('branch')
 
786
        try:
 
787
            branch.bind(master1)
 
788
        except errors.UpgradeRequired:
 
789
            raise tests.TestNotApplicable('Format does not support binding')
 
790
        self.addCleanup(branch.lock_write().unlock)
 
791
        self.assertNotEqual(None, branch.get_master_branch())
 
792
        branch.set_bound_location(self.get_url('master2'))
 
793
        self.assertEqual('.', urlutils.relative_url(self.get_url('master2'),
 
794
                branch.get_master_branch().base))
 
795
 
739
796
 
740
797
class TestStrict(per_branch.TestCaseWithBranch):
741
798