71
71
def test_break_lock_everything_locked(self):
72
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()
76
80
self.master_branch.lock_write()
77
81
# run the break-lock
78
82
# we need 5 yes's - wt, branch, repo, bound branch, bound repo.
79
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")
80
84
# a new tree instance should be lockable
81
wt = bzrlib.workingtree.WorkingTree.open('checkout')
85
branch = bzrlib.branch.Branch.open('checkout')
84
88
# and a new instance of the master branch
85
mb = wt.branch.get_master_branch()
89
mb = branch.get_master_branch()
88
92
self.assertRaises(errors.LockBroken, self.wt.unlock)
89
93
self.assertRaises(errors.LockBroken, self.master_branch.unlock)
91
def test_saying_no_leaves_it_locked(self):
92
### if 'no' is answered, objects should remain locked.
95
self.master_branch.lock_write()
98
# we need 5 yes's - wt, branch, repo, bound branch, bound repo.
99
self.run_bzr('break-lock', 'checkout', stdin="n\nn\nn\nn\nn\n")
101
# The default timeout to wait for LockContention is 5 minutes.
102
# we need to override this temporarily.
103
# TODO: jam 20060927 When we have per repository/branch/tree
104
# timeouts set the value of the repository,
105
# rather than setting the global default.
106
orig_default = lockdir._DEFAULT_TIMEOUT_SECONDS
108
lockdir._DEFAULT_TIMEOUT_SECONDS = 1
109
# a new tree instance should not be lockable
110
wt = bzrlib.workingtree.WorkingTree.open('checkout')
111
self.assertRaises(errors.LockContention, wt.lock_write)
112
# and a new instance of the master branch
113
mb = wt.branch.get_master_branch()
114
self.assertRaises(errors.LockContention, mb.lock_write)
116
lockdir._DEFAULT_TIMEOUT_SECONDS = orig_default
117
# unlock our branches normally.
119
self.master_branch.unlock()
123
96
class TestBreakLockOldBranch(ExternalBase):