330
328
# config file in the branch.
331
329
branch.nick = "Aaron's branch"
332
330
if not isinstance(branch, remote.RemoteBranch):
333
self.failUnless(branch._transport.has("branch.conf"))
331
self.assertTrue(branch._transport.has("branch.conf"))
334
332
# Because the nick has been set explicitly, the nick is now always
335
333
# "Aaron's branch", regardless of directory name.
336
334
self.assertEqual(branch.nick, "Aaron's branch")
462
460
tree = self.make_branch_and_tree('a')
463
461
tree.commit('a commit', rev_id='rev1')
465
br.set_revision_history(["rev1"])
463
self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
464
br.set_revision_history, ["rev1"])
466
465
self.assertEquals(br.revision_history(), ["rev1"])
467
br.set_revision_history([])
466
self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
467
br.set_revision_history, [])
468
468
self.assertEquals(br.revision_history(), [])
470
470
def test_heads_to_fetch(self):
675
675
t = self.get_transport()
676
676
readonly_t = transport.get_transport(self.get_readonly_url())
677
677
made_branch = self.make_branch('.')
678
self.failUnless(isinstance(made_branch, _mod_branch.Branch))
678
self.assertIsInstance(made_branch, _mod_branch.Branch)
680
680
# find it via bzrdir opening:
681
681
opened_control = bzrdir.BzrDir.open(readonly_t.base)
682
682
direct_opened_branch = opened_control.open_branch()
683
683
self.assertEqual(direct_opened_branch.__class__, made_branch.__class__)
684
684
self.assertEqual(opened_control, direct_opened_branch.bzrdir)
685
self.failUnless(isinstance(direct_opened_branch._format,
686
self.branch_format.__class__))
685
self.assertIsInstance(direct_opened_branch._format,
686
self.branch_format.__class__)
688
688
# find it via Branch.open
689
689
opened_branch = _mod_branch.Branch.open(readonly_t.base)
690
self.failUnless(isinstance(opened_branch, made_branch.__class__))
690
self.assertIsInstance(opened_branch, made_branch.__class__)
691
691
self.assertEqual(made_branch._format.__class__,
692
692
opened_branch._format.__class__)
693
693
# if it has a unique id string, can we probe for it ?
736
736
except errors.UpgradeRequired:
737
737
raise tests.TestNotApplicable('Format does not support binding')
739
def test_unbind_clears_cached_master_branch(self):
740
"""b.unbind clears any cached value of b.get_master_branch."""
741
master = self.make_branch('master')
742
branch = self.make_branch('branch')
745
except errors.UpgradeRequired:
746
raise tests.TestNotApplicable('Format does not support binding')
747
self.addCleanup(branch.lock_write().unlock)
748
self.assertNotEqual(None, branch.get_master_branch())
750
self.assertEqual(None, branch.get_master_branch())
752
def test_unlocked_does_not_cache_master_branch(self):
753
"""Unlocked branches do not cache the result of get_master_branch."""
754
master = self.make_branch('master')
755
branch1 = self.make_branch('branch')
758
except errors.UpgradeRequired:
759
raise tests.TestNotApplicable('Format does not support binding')
761
branch2 = branch1.bzrdir.open_branch()
762
self.assertNotEqual(None, branch1.get_master_branch())
763
# Unbind the branch via branch2. branch1 isn't locked so will
764
# immediately return the new value for get_master_branch.
766
self.assertEqual(None, branch1.get_master_branch())
768
def test_bind_clears_cached_master_branch(self):
769
"""b.bind clears any cached value of b.get_master_branch."""
770
master1 = self.make_branch('master1')
771
master2 = self.make_branch('master2')
772
branch = self.make_branch('branch')
775
except errors.UpgradeRequired:
776
raise tests.TestNotApplicable('Format does not support binding')
777
self.addCleanup(branch.lock_write().unlock)
778
self.assertNotEqual(None, branch.get_master_branch())
780
self.assertEqual('.', urlutils.relative_url(self.get_url('master2'),
781
branch.get_master_branch().base))
783
def test_set_bound_location_clears_cached_master_branch(self):
784
"""b.set_bound_location clears any cached value of b.get_master_branch.
786
master1 = self.make_branch('master1')
787
master2 = self.make_branch('master2')
788
branch = self.make_branch('branch')
791
except errors.UpgradeRequired:
792
raise tests.TestNotApplicable('Format does not support binding')
793
self.addCleanup(branch.lock_write().unlock)
794
self.assertNotEqual(None, branch.get_master_branch())
795
branch.set_bound_location(self.get_url('master2'))
796
self.assertEqual('.', urlutils.relative_url(self.get_url('master2'),
797
branch.get_master_branch().base))
740
800
class TestStrict(per_branch.TestCaseWithBranch):