bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
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 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
19 |
from breezy import ( |
|
5356.1.1
by Vincent Ladeuil
Cleanup test imports. |
20 |
branch, |
|
5345.5.9
by Vincent Ladeuil
Implements 'bzr lock --config <file>'. |
21 |
config, |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
22 |
controldir, |
|
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
23 |
errors, |
|
5345.5.9
by Vincent Ladeuil
Implements 'bzr lock --config <file>'. |
24 |
osutils, |
|
5356.1.1
by Vincent Ladeuil
Cleanup test imports. |
25 |
tests, |
|
1957.1.17
by John Arbash Meinel
Change tests that expect locking to fail to timeout sooner. |
26 |
)
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
27 |
from breezy.tests.script import ( |
|
5416.2.3
by Martin Pool
Better test for break-lock; show lock URLs as they're broken |
28 |
run_script, |
|
5416.2.1
by Martin Pool
Add 'break-lock --force' |
29 |
)
|
|
5356.1.1
by Vincent Ladeuil
Cleanup test imports. |
30 |
|
31 |
||
32 |
class TestBreakLock(tests.TestCaseWithTransport): |
|
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
33 |
|
34 |
# General principal for break-lock: All the elements that might be locked
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
35 |
# by a brz operation on PATH, are candidates that break-lock may unlock.
|
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
36 |
# so pathologically if we have a lightweight checkout A, of branch B, which
|
37 |
# is bound to location C, the following things should be checked for locks
|
|
38 |
# to break:
|
|
39 |
# wt = WorkingTree(A)
|
|
40 |
# wt.branch
|
|
41 |
# wt.branch.repository
|
|
42 |
# wt.branch.get_master_branch()
|
|
43 |
# wt.branch.get_master_branch().repository
|
|
44 |
# so for smoke tests all we need is a bound branch with a checkout of that
|
|
45 |
# and we can then use different urls to test individual cases, for as much
|
|
46 |
# granularity as needed.
|
|
47 |
||
48 |
def setUp(self): |
|
49 |
super(TestBreakLock, self).setUp() |
|
50 |
self.build_tree( |
|
51 |
['master-repo/', |
|
52 |
'master-repo/master-branch/', |
|
53 |
'repo/', |
|
54 |
'repo/branch/', |
|
55 |
'checkout/']) |
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
56 |
controldir.ControlDir.create('master-repo').create_repository() |
57 |
self.master_branch = controldir.ControlDir.create_branch_convenience( |
|
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
58 |
'master-repo/master-branch') |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
59 |
controldir.ControlDir.create('repo').create_repository() |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
60 |
local_branch = controldir.ControlDir.create_branch_convenience( |
61 |
'repo/branch') |
|
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
62 |
local_branch.bind(self.master_branch) |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
63 |
checkoutdir = controldir.ControlDir.create('checkout') |
|
6437.7.3
by Jelmer Vernooij
Use ControlDir.set_branch_reference. |
64 |
checkoutdir.set_branch_reference(local_branch) |
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
65 |
self.wt = checkoutdir.create_workingtree() |
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
66 |
|
|
1553.5.34
by Martin Pool
Stub lock-breaking command |
67 |
def test_break_lock_help(self): |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
68 |
out, err = self.run_bzr('break-lock --help') |
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
69 |
# shouldn't fail and should not produce error output
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
70 |
self.assertEqual('', err) |
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
71 |
|
|
5416.2.1
by Martin Pool
Add 'break-lock --force' |
72 |
def test_break_lock_no_interaction(self): |
73 |
"""With --force, the user isn't asked for confirmation""" |
|
|
5416.2.3
by Martin Pool
Better test for break-lock; show lock URLs as they're broken |
74 |
self.master_branch.lock_write() |
75 |
run_script(self, """ |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
76 |
$ brz break-lock --force master-repo/master-branch
|
|
5416.2.3
by Martin Pool
Better test for break-lock; show lock URLs as they're broken |
77 |
Broke lock ...master-branch/.bzr/...
|
|
5416.2.1
by Martin Pool
Add 'break-lock --force' |
78 |
""") |
79 |
# lock should now be dead
|
|
|
5416.2.3
by Martin Pool
Better test for break-lock; show lock URLs as they're broken |
80 |
self.assertRaises(errors.LockBroken, self.master_branch.unlock) |
|
5416.2.1
by Martin Pool
Add 'break-lock --force' |
81 |
|
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
82 |
def test_break_lock_everything_locked(self): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
83 |
# 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 |
84 |
# however, we dont test breaking the working tree because we
|
85 |
# 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. |
86 |
# by an os lock, and we need to spawn a separate process to lock it
|
|
5345.5.2
by Vincent Ladeuil
Fix typo. |
87 |
# then kill -9 it.
|
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
88 |
# 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. |
89 |
# lock most of the dir:
|
90 |
self.wt.branch.lock_write() |
|
|
1687.1.1
by Robert Collins
Document what the break-lock commands should be like |
91 |
self.master_branch.lock_write() |
92 |
# run the break-lock
|
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
93 |
# 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. |
94 |
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. |
95 |
# a new tree instance should be lockable
|
|
5356.1.1
by Vincent Ladeuil
Cleanup test imports. |
96 |
br = branch.Branch.open('checkout') |
97 |
br.lock_write() |
|
98 |
br.unlock() |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
99 |
# and a new instance of the master branch
|
|
5356.1.1
by Vincent Ladeuil
Cleanup test imports. |
100 |
mb = br.get_master_branch() |
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
101 |
mb.lock_write() |
102 |
mb.unlock() |
|
103 |
self.assertRaises(errors.LockBroken, self.wt.unlock) |
|
104 |
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. |
105 |
|
|
1687.1.17
by Robert Collins
Test break lock on old format branches. |
106 |
|
|
5345.5.9
by Vincent Ladeuil
Implements 'bzr lock --config <file>'. |
107 |
class TestConfigBreakLock(tests.TestCaseWithTransport): |
108 |
||
109 |
def setUp(self): |
|
110 |
super(TestConfigBreakLock, self).setUp() |
|
111 |
self.config_file_name = './my.conf' |
|
112 |
self.build_tree_contents([(self.config_file_name, |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
113 |
b'[DEFAULT]\none=1\n')]) |
|
5345.5.9
by Vincent Ladeuil
Implements 'bzr lock --config <file>'. |
114 |
self.config = config.LockableConfig(file_name=self.config_file_name) |
115 |
self.config.lock_write() |
|
116 |
||
117 |
def test_create_pending_lock(self): |
|
118 |
self.addCleanup(self.config.unlock) |
|
119 |
self.assertTrue(self.config._lock.is_held) |
|
120 |
||
121 |
def test_break_lock(self): |
|
122 |
self.run_bzr('break-lock --config %s' |
|
123 |
% osutils.dirname(self.config_file_name), |
|
124 |
stdin="y\n") |
|
125 |
self.assertRaises(errors.LockBroken, self.config.unlock) |
|
126 |