~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_break_lock.py

  • Committer: Robert Collins
  • Date: 2006-05-04 13:26:31 UTC
  • mto: (1697.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: robertc@robertcollins.net-20060504132631-ab199c12d7427f82
Branch.break_lock should handle bound branches too

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
    def setUp(self):
30
30
        super(TestBreakLock, self).setUp()
31
 
        self.unused_branch = self.make_branch('.')
 
31
        self.unused_branch = self.make_branch('branch')
32
32
        self.branch = self.unused_branch.bzrdir.open_branch()
33
33
        # we want a UI factory that accepts canned input for the tests:
34
34
        # while SilentUIFactory still accepts stdin, we need to customise
49
49
    def test_unlocked_repo_locked(self):
50
50
        # break lock on the branch should try on the repository even
51
51
        # if the branch isn't locked
52
 
        # break_lock when locked should
53
52
        self.branch.repository.lock_write()
54
53
        bzrlib.ui.ui_factory.stdin = StringIO("y\n")
55
54
        try:
61
60
        self.assertRaises(errors.LockBroken, self.branch.repository.unlock)
62
61
 
63
62
    def test_locked(self):
64
 
        # break_lock when locked should
 
63
        # break_lock when locked should unlock the branch and repo
65
64
        self.branch.lock_write()
66
65
        bzrlib.ui.ui_factory.stdin = StringIO("y\ny\n")
67
66
        try:
71
70
            self.branch.unlock()
72
71
            return
73
72
        self.assertRaises(errors.LockBroken, self.branch.unlock)
 
73
 
 
74
    def test_unlocks_master_branch(self):
 
75
        # break_lock when when the master branch is locked should offer to
 
76
        # unlock it.
 
77
        master = self.make_branch('master')
 
78
        try:
 
79
            self.branch.bind(master)
 
80
        except errors.UpgradeRequired:
 
81
            # this branch does not support binding.
 
82
            return
 
83
        master.lock_write()
 
84
        bzrlib.ui.ui_factory.stdin = StringIO("y\ny\n")
 
85
        try:
 
86
            self.unused_branch.break_lock()
 
87
        except NotImplementedError:
 
88
            # branch does not support break_lock
 
89
            master.unlock()
 
90
            return
 
91
        self.assertRaises(errors.LockBroken, master.unlock)
 
92
        # can we lock it now ?
 
93
        master.lock_write()
 
94
        master.unlock()
 
95