1
1
# Copyright (C) 2006 Canonical Ltd
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
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
68
71
def test_break_lock_everything_locked(self):
69
72
### if everything is locked, we should be able to unlock the lot.
73
# however, we dont test breaking the working tree because we
74
# cannot accurately do so right now: the dirstate lock is held
75
# by an os lock, and we need to spawn a separate process to lock it
78
# lock most of the dir:
79
self.wt.branch.lock_write()
73
80
self.master_branch.lock_write()
74
81
# run the break-lock
75
82
# we need 5 yes's - wt, branch, repo, bound branch, bound repo.
76
self.run_bzr('break-lock', 'checkout', stdin="y\ny\ny\ny\ny\n")
83
self.run_bzr('break-lock', 'checkout', stdin="y\ny\ny\ny\n")
77
84
# a new tree instance should be lockable
78
wt = bzrlib.workingtree.WorkingTree.open('checkout')
85
branch = bzrlib.branch.Branch.open('checkout')
81
88
# and a new instance of the master branch
82
mb = wt.branch.get_master_branch()
89
mb = branch.get_master_branch()
85
92
self.assertRaises(errors.LockBroken, self.wt.unlock)
86
93
self.assertRaises(errors.LockBroken, self.master_branch.unlock)
88
def test_saying_no_leaves_it_locked(self):
89
### if 'no' is answered, objects should remain locked.
91
self.master_branch.lock_write()
93
# we need 5 yes's - wt, branch, repo, bound branch, bound repo.
94
self.run_bzr('break-lock', 'checkout', stdin="n\nn\nn\nn\nn\n")
95
# a new tree instance should not be lockable
96
wt = bzrlib.workingtree.WorkingTree.open('checkout')
97
self.assertRaises(errors.LockContention, wt.lock_write)
98
# and a new instance of the master branch
99
mb = wt.branch.get_master_branch()
100
self.assertRaises(errors.LockContention, mb.lock_write)
101
# unlock our branches normally.
103
self.master_branch.unlock()
106
96
class TestBreakLockOldBranch(ExternalBase):