4597.9.2
by Vincent Ladeuil
Merge bzr.dev into cleanup |
1 |
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1553.5.34
by Martin Pool
Stub lock-breaking command |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
1553.5.34
by Martin Pool
Stub lock-breaking command |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
1553.5.34
by Martin Pool
Stub lock-breaking command |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1553.5.34
by Martin Pool
Stub lock-breaking command |
16 |
|
17 |
"""Tests for lock-breaking user interface"""
|
|
18 |
||
19 |
import os |
|
20 |
||
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
21 |
import bzrlib |
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
22 |
from bzrlib import ( |
23 |
errors, |
|
24 |
lockdir, |
|
25 |
)
|
|
1553.5.34
by Martin Pool
Stub lock-breaking command |
26 |
from bzrlib.branch import Branch |
1553.5.35
by Martin Pool
Start break-lock --show |
27 |
from bzrlib.bzrdir import BzrDir |
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
28 |
from bzrlib.tests import TestCaseWithTransport |
29 |
||
30 |
||
31 |
class TestBreakLock(TestCaseWithTransport): |
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
32 |
|
33 |
# General principal for break-lock: All the elements that might be locked
|
|
34 |
# by a bzr operation on PATH, are candidates that break-lock may unlock.
|
|
35 |
# so pathologically if we have a lightweight checkout A, of branch B, which
|
|
36 |
# is bound to location C, the following things should be checked for locks
|
|
37 |
# to break:
|
|
38 |
# wt = WorkingTree(A)
|
|
39 |
# wt.branch
|
|
40 |
# wt.branch.repository
|
|
41 |
# wt.branch.get_master_branch()
|
|
42 |
# wt.branch.get_master_branch().repository
|
|
43 |
# so for smoke tests all we need is a bound branch with a checkout of that
|
|
44 |
# and we can then use different urls to test individual cases, for as much
|
|
45 |
# granularity as needed.
|
|
46 |
||
47 |
def setUp(self): |
|
48 |
super(TestBreakLock, self).setUp() |
|
49 |
self.build_tree( |
|
50 |
['master-repo/', |
|
51 |
'master-repo/master-branch/', |
|
52 |
'repo/', |
|
53 |
'repo/branch/', |
|
54 |
'checkout/']) |
|
55 |
bzrlib.bzrdir.BzrDir.create('master-repo').create_repository() |
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
56 |
self.master_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience( |
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
57 |
'master-repo/master-branch') |
58 |
bzrlib.bzrdir.BzrDir.create('repo').create_repository() |
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
59 |
local_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('repo/branch') |
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
60 |
local_branch.bind(self.master_branch) |
61 |
checkoutdir = bzrlib.bzrdir.BzrDir.create('checkout') |
|
62 |
bzrlib.branch.BranchReferenceFormat().initialize( |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
63 |
checkoutdir, target_branch=local_branch) |
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
64 |
self.wt = checkoutdir.create_workingtree() |
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
65 |
|
1553.5.34
by Martin Pool
Stub lock-breaking command |
66 |
def test_break_lock_help(self): |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
67 |
out, err = self.run_bzr('break-lock --help') |
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
68 |
# shouldn't fail and should not produce error output
|
69 |
self.assertEqual('', err) |
|
70 |
||
71 |
def test_break_lock_everything_locked(self): |
|
72 |
### if everything is locked, we should be able to unlock the lot.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
73 |
# however, we dont test breaking the working tree because we
|
74 |
# cannot accurately do so right now: the dirstate lock is held
|
|
2255.2.143
by Robert Collins
Update break-lock blackbox test to not break with dirstate as the default tree format. Unfortunately this slightly reduces test coverage of the UI. |
75 |
# by an os lock, and we need to spawn a separate process to lock it
|
76 |
# thne kill -9 it.
|
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
77 |
# sketch of test:
|
2255.2.143
by Robert Collins
Update break-lock blackbox test to not break with dirstate as the default tree format. Unfortunately this slightly reduces test coverage of the UI. |
78 |
# lock most of the dir:
|
79 |
self.wt.branch.lock_write() |
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
80 |
self.master_branch.lock_write() |
81 |
# run the break-lock
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
82 |
# we need 5 yes's - wt, branch, repo, bound branch, bound repo.
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
83 |
self.run_bzr('break-lock checkout', stdin="y\ny\ny\ny\n") |
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
84 |
# a new tree instance should be lockable
|
2255.2.143
by Robert Collins
Update break-lock blackbox test to not break with dirstate as the default tree format. Unfortunately this slightly reduces test coverage of the UI. |
85 |
branch = bzrlib.branch.Branch.open('checkout') |
86 |
branch.lock_write() |
|
87 |
branch.unlock() |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
88 |
# and a new instance of the master branch
|
2255.2.143
by Robert Collins
Update break-lock blackbox test to not break with dirstate as the default tree format. Unfortunately this slightly reduces test coverage of the UI. |
89 |
mb = branch.get_master_branch() |
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
90 |
mb.lock_write() |
91 |
mb.unlock() |
|
92 |
self.assertRaises(errors.LockBroken, self.wt.unlock) |
|
93 |
self.assertRaises(errors.LockBroken, self.master_branch.unlock) |
|
1687.1.16
by Robert Collins
Ensure that answering no to break lock leaves the locks in place. This is currently simple - ask for everything always. |
94 |
|
1687.1.17
by Robert Collins
Test break lock on old format branches. |
95 |
|
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
96 |
class TestBreakLockOldBranch(TestCaseWithTransport): |
1687.1.17
by Robert Collins
Test break lock on old format branches. |
97 |
|
98 |
def test_break_lock_format_5_bzrdir(self): |
|
99 |
# break lock on a format 5 bzrdir should just return
|
|
100 |
self.make_branch_and_tree('foo', format=bzrlib.bzrdir.BzrDirFormat5()) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
101 |
out, err = self.run_bzr('break-lock foo') |
1687.1.17
by Robert Collins
Test break lock on old format branches. |
102 |
self.assertEqual('', out) |
103 |
self.assertEqual('', err) |