~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2012-04-16 11:08:11 UTC
  • mfrom: (6521 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6522.
  • Revision ID: jelmer@samba.org-20120416110811-0y996ihqy9o2bb1t
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
 
19
19
from bzrlib import (
20
20
    branch as _mod_branch,
21
 
    bzrdir,
 
21
    controldir,
22
22
    config,
23
23
    delta as _mod_delta,
24
24
    errors,
25
 
    gpg,
26
25
    merge,
27
26
    osutils,
28
27
    urlutils,
476
475
        checkout = source_branch.create_checkout('c')
477
476
        self.assertEqual(rev_id, checkout.last_revision())
478
477
 
479
 
    def test_set_revision_history(self):
480
 
        tree = self.make_branch_and_tree('a')
481
 
        tree.commit('a commit', rev_id='rev1')
482
 
        br = tree.branch
483
 
        self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
484
 
            br.set_revision_history, ["rev1"])
485
 
        self.assertEquals(br.last_revision(), "rev1")
486
 
        self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
487
 
            br.set_revision_history, [])
488
 
        self.assertEquals(br.last_revision(), 'null:')
489
 
 
490
478
    def test_heads_to_fetch(self):
491
479
        # heads_to_fetch is a method that returns a collection of revids that
492
480
        # need to be fetched to copy this branch into another repo.  At a
529
517
            looked_up_format = registry.get(network_name)
530
518
            self.assertEqual(format.__class__, looked_up_format.__class__)
531
519
 
532
 
    def get_get_config_calls(self):
 
520
    def test_get_config_calls(self):
533
521
        # Smoke test that all branch succeed getting a config
534
522
        br = self.make_branch('.')
535
523
        br.get_config()
709
697
        self.assertIsInstance(made_branch, _mod_branch.Branch)
710
698
 
711
699
        # find it via bzrdir opening:
712
 
        opened_control = bzrdir.BzrDir.open(readonly_t.base)
 
700
        opened_control = controldir.ControlDir.open(readonly_t.base)
713
701
        direct_opened_branch = opened_control.open_branch()
714
702
        self.assertEqual(direct_opened_branch.__class__, made_branch.__class__)
715
703
        self.assertEqual(opened_control, direct_opened_branch.bzrdir)
780
768
        branch.unbind()
781
769
        self.assertEqual(None, branch.get_master_branch())
782
770
 
783
 
    def test_unlocked_does_not_cache_master_branch(self):
784
 
        """Unlocked branches do not cache the result of get_master_branch."""
785
 
        master = self.make_branch('master')
786
 
        branch1 = self.make_branch('branch')
787
 
        try:
788
 
            branch1.bind(master)
789
 
        except errors.UpgradeRequired:
790
 
            raise tests.TestNotApplicable('Format does not support binding')
791
 
        # Open branch1 again
792
 
        branch2 = branch1.bzrdir.open_branch()
793
 
        self.assertNotEqual(None, branch1.get_master_branch())
794
 
        # Unbind the branch via branch2.  branch1 isn't locked so will
795
 
        # immediately return the new value for get_master_branch.
796
 
        branch2.unbind()
797
 
        self.assertEqual(None, branch1.get_master_branch())
798
 
 
799
771
    def test_bind_clears_cached_master_branch(self):
800
772
        """b.bind clears any cached value of b.get_master_branch."""
801
773
        master1 = self.make_branch('master1')
866
838
    def test_fallbacks_not_opened(self):
867
839
        stacked = self.make_branch_with_fallback()
868
840
        self.get_transport('').rename('fallback', 'moved')
869
 
        reopened_dir = bzrdir.BzrDir.open(stacked.base)
 
841
        reopened_dir = controldir.ControlDir.open(stacked.base)
870
842
        reopened = reopened_dir.open_branch(ignore_fallbacks=True)
871
843
        self.assertEqual([], reopened.repository._fallback_repositories)
872
844
 
873
845
    def test_fallbacks_are_opened(self):
874
846
        stacked = self.make_branch_with_fallback()
875
 
        reopened_dir = bzrdir.BzrDir.open(stacked.base)
 
847
        reopened_dir = controldir.ControlDir.open(stacked.base)
876
848
        reopened = reopened_dir.open_branch(ignore_fallbacks=False)
877
849
        self.assertLength(1, reopened.repository._fallback_repositories)
878
850