bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.2
by Vincent Ladeuil
Fix assertNotEquals being deprecated by using assertNotEqual. |
1 |
# Copyright (C) 2008-2011, 2016 Canonical Ltd
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
2 |
#
|
|
0.16.101
by Aaron Bentley
Update GPL formatting and copyright |
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
16 |
|
17 |
||
|
0.16.91
by Aaron Bentley
Test finish and quit |
18 |
import os |
|
0.16.108
by Aaron Bentley
Shelf supports multiple diff writers. |
19 |
import sys |
|
4902.1.6
by Guilherme Salgado
Tweak the text to check to assert the meat of the diff is what we expect, instead of just checking it matches some regexps |
20 |
from textwrap import dedent |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
21 |
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
22 |
from .. import ( |
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
23 |
errors, |
24 |
shelf_ui, |
|
25 |
revision, |
|
26 |
tests, |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
27 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
28 |
from ..sixish import ( |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
29 |
BytesIO, |
30 |
)
|
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
31 |
from . import script |
32 |
from . import ( |
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
33 |
features, |
34 |
)
|
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
35 |
|
36 |
||
37 |
class ExpectShelver(shelf_ui.Shelver): |
|
38 |
"""A variant of Shelver that intercepts console activity, for testing.""" |
|
39 |
||
|
4100.3.4
by Aaron Bentley
Clean up signatures |
40 |
def __init__(self, work_tree, target_tree, diff_writer=None, |
41 |
auto=False, auto_apply=False, file_list=None, message=None, |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
42 |
destroy=False, reporter=None): |
|
0.16.108
by Aaron Bentley
Shelf supports multiple diff writers. |
43 |
shelf_ui.Shelver.__init__(self, work_tree, target_tree, diff_writer, |
|
4100.3.4
by Aaron Bentley
Clean up signatures |
44 |
auto, auto_apply, file_list, message, |
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
45 |
destroy, reporter=reporter) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
46 |
self.expected = [] |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
47 |
self.diff_writer = BytesIO() |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
48 |
|
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
49 |
def expect(self, message, response): |
50 |
self.expected.append((message, response)) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
51 |
|
|
6182.2.8
by Benoît Pierre
Fix shelf_ui tests. |
52 |
def prompt(self, message, choices, default): |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
53 |
try: |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
54 |
expected_message, response = self.expected.pop(0) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
55 |
except IndexError: |
56 |
raise AssertionError('Unexpected prompt: %s' % message) |
|
|
6182.2.8
by Benoît Pierre
Fix shelf_ui tests. |
57 |
if message != expected_message: |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
58 |
raise AssertionError('Wrong prompt: %s' % message) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
59 |
if choices != '&yes\n&No\n&finish\n&quit': |
|
6182.2.8
by Benoît Pierre
Fix shelf_ui tests. |
60 |
raise AssertionError('Wrong choices: %s' % choices) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
61 |
return response |
62 |
||
63 |
||
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
64 |
LINES_AJ = 'a\nb\nc\nd\ne\nf\ng\nh\ni\nj\n' |
65 |
||
66 |
||
67 |
LINES_ZY = 'z\nb\nc\nd\ne\nf\ng\nh\ni\ny\n' |
|
68 |
||
69 |
||
70 |
LINES_AY = 'a\nb\nc\nd\ne\nf\ng\nh\ni\ny\n' |
|
71 |
||
72 |
||
|
5954.2.3
by Aaron Bentley
Fix test duplication in TestApplyReporter |
73 |
class ShelfTestCase(tests.TestCaseWithTransport): |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
74 |
|
75 |
def create_shelvable_tree(self): |
|
76 |
tree = self.make_branch_and_tree('tree') |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
77 |
self.build_tree_contents([('tree/foo', LINES_AJ)]) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
78 |
tree.add('foo', 'foo-id') |
79 |
tree.commit('added foo') |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
80 |
self.build_tree_contents([('tree/foo', LINES_ZY)]) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
81 |
return tree |
82 |
||
|
5954.2.3
by Aaron Bentley
Fix test duplication in TestApplyReporter |
83 |
|
84 |
class TestShelver(ShelfTestCase): |
|
85 |
||
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
86 |
def test_unexpected_prompt_failure(self): |
87 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
88 |
tree.lock_tree_write() |
89 |
self.addCleanup(tree.unlock) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
90 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
91 |
self.addCleanup(shelver.finalize) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
92 |
e = self.assertRaises(AssertionError, shelver.run) |
|
6182.2.8
by Benoît Pierre
Fix shelf_ui tests. |
93 |
self.assertEqual('Unexpected prompt: Shelve?', str(e)) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
94 |
|
95 |
def test_wrong_prompt_failure(self): |
|
96 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
97 |
tree.lock_tree_write() |
98 |
self.addCleanup(tree.unlock) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
99 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
100 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
101 |
shelver.expect('foo', 0) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
102 |
e = self.assertRaises(AssertionError, shelver.run) |
|
6182.2.8
by Benoît Pierre
Fix shelf_ui tests. |
103 |
self.assertEqual('Wrong prompt: Shelve?', str(e)) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
104 |
|
105 |
def test_shelve_not_diff(self): |
|
106 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
107 |
tree.lock_tree_write() |
108 |
self.addCleanup(tree.unlock) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
109 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
110 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
111 |
shelver.expect('Shelve?', 1) |
112 |
shelver.expect('Shelve?', 1) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
113 |
# No final shelving prompt because no changes were selected
|
114 |
shelver.run() |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
115 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
116 |
|
117 |
def test_shelve_diff_no(self): |
|
118 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
119 |
tree.lock_tree_write() |
120 |
self.addCleanup(tree.unlock) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
121 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
122 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
123 |
shelver.expect('Shelve?', 0) |
124 |
shelver.expect('Shelve?', 0) |
|
125 |
shelver.expect('Shelve 2 change(s)?', 1) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
126 |
shelver.run() |
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
127 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
128 |
|
129 |
def test_shelve_diff(self): |
|
130 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
131 |
tree.lock_tree_write() |
132 |
self.addCleanup(tree.unlock) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
133 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
134 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
135 |
shelver.expect('Shelve?', 0) |
136 |
shelver.expect('Shelve?', 0) |
|
137 |
shelver.expect('Shelve 2 change(s)?', 0) |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
138 |
shelver.run() |
139 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
140 |
||
141 |
def test_shelve_one_diff(self): |
|
142 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
143 |
tree.lock_tree_write() |
144 |
self.addCleanup(tree.unlock) |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
145 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
146 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
147 |
shelver.expect('Shelve?', 0) |
148 |
shelver.expect('Shelve?', 1) |
|
149 |
shelver.expect('Shelve 1 change(s)?', 0) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
150 |
shelver.run() |
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
151 |
self.assertFileEqual(LINES_AY, 'tree/foo') |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
152 |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
153 |
def test_shelve_binary_change(self): |
154 |
tree = self.create_shelvable_tree() |
|
155 |
self.build_tree_contents([('tree/foo', '\x00')]) |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
156 |
tree.lock_tree_write() |
157 |
self.addCleanup(tree.unlock) |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
158 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
159 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
160 |
shelver.expect('Shelve binary changes?', 0) |
161 |
shelver.expect('Shelve 1 change(s)?', 0) |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
162 |
shelver.run() |
163 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
164 |
||
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
165 |
def test_shelve_rename(self): |
166 |
tree = self.create_shelvable_tree() |
|
167 |
tree.rename_one('foo', 'bar') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
168 |
tree.lock_tree_write() |
169 |
self.addCleanup(tree.unlock) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
170 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
171 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
172 |
shelver.expect('Shelve renaming "foo" => "bar"?', 0) |
173 |
shelver.expect('Shelve?', 0) |
|
174 |
shelver.expect('Shelve?', 0) |
|
175 |
shelver.expect('Shelve 3 change(s)?', 0) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
176 |
shelver.run() |
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
177 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
0.16.91
by Aaron Bentley
Test finish and quit |
178 |
|
179 |
def test_shelve_deletion(self): |
|
180 |
tree = self.create_shelvable_tree() |
|
181 |
os.unlink('tree/foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
182 |
tree.lock_tree_write() |
183 |
self.addCleanup(tree.unlock) |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
184 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
185 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
186 |
shelver.expect('Shelve removing file "foo"?', 0) |
187 |
shelver.expect('Shelve 1 change(s)?', 0) |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
188 |
shelver.run() |
189 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
190 |
||
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
191 |
def test_shelve_creation(self): |
192 |
tree = self.make_branch_and_tree('tree') |
|
193 |
tree.commit('add tree root') |
|
194 |
self.build_tree(['tree/foo']) |
|
195 |
tree.add('foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
196 |
tree.lock_tree_write() |
197 |
self.addCleanup(tree.unlock) |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
198 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
199 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
200 |
shelver.expect('Shelve adding file "foo"?', 0) |
201 |
shelver.expect('Shelve 1 change(s)?', 0) |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
202 |
shelver.run() |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
203 |
self.assertPathDoesNotExist('tree/foo') |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
204 |
|
205 |
def test_shelve_kind_change(self): |
|
206 |
tree = self.create_shelvable_tree() |
|
207 |
os.unlink('tree/foo') |
|
208 |
os.mkdir('tree/foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
209 |
tree.lock_tree_write() |
210 |
self.addCleanup(tree.unlock) |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
211 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
212 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
213 |
shelver.expect('Shelve changing "foo" from file to directory?', |
|
6182.2.8
by Benoît Pierre
Fix shelf_ui tests. |
214 |
0) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
215 |
shelver.expect('Shelve 1 change(s)?', 0) |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
216 |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
217 |
def test_shelve_modify_target(self): |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
218 |
self.requireFeature(features.SymlinkFeature) |
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
219 |
tree = self.create_shelvable_tree() |
220 |
os.symlink('bar', 'tree/baz') |
|
221 |
tree.add('baz', 'baz-id') |
|
222 |
tree.commit("Add symlink") |
|
223 |
os.unlink('tree/baz') |
|
224 |
os.symlink('vax', 'tree/baz') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
225 |
tree.lock_tree_write() |
226 |
self.addCleanup(tree.unlock) |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
227 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
228 |
self.addCleanup(shelver.finalize) |
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
229 |
shelver.expect('Shelve changing target of "baz" from "bar" to ' |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
230 |
'"vax"?', 0) |
231 |
shelver.expect('Shelve 1 change(s)?', 0) |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
232 |
shelver.run() |
233 |
self.assertEqual('bar', os.readlink('tree/baz')) |
|
234 |
||
|
0.16.91
by Aaron Bentley
Test finish and quit |
235 |
def test_shelve_finish(self): |
236 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
237 |
tree.lock_tree_write() |
238 |
self.addCleanup(tree.unlock) |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
239 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
240 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
241 |
shelver.expect('Shelve?', 2) |
242 |
shelver.expect('Shelve 2 change(s)?', 0) |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
243 |
shelver.run() |
244 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
245 |
||
246 |
def test_shelve_quit(self): |
|
247 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
248 |
tree.lock_tree_write() |
249 |
self.addCleanup(tree.unlock) |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
250 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
251 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
252 |
shelver.expect('Shelve?', 3) |
|
0.16.103
by Aaron Bentley
raise UserAbort instead of doing sys.exit |
253 |
self.assertRaises(errors.UserAbort, shelver.run) |
|
0.16.91
by Aaron Bentley
Test finish and quit |
254 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
255 |
|
256 |
def test_shelve_all(self): |
|
257 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
258 |
shelver = ExpectShelver.from_args(sys.stdout, all=True, |
259 |
directory='tree') |
|
260 |
try: |
|
261 |
shelver.run() |
|
262 |
finally: |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
263 |
shelver.finalize() |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
264 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
0.16.93
by Aaron Bentley
Test shelving one file |
265 |
|
266 |
def test_shelve_filename(self): |
|
267 |
tree = self.create_shelvable_tree() |
|
268 |
self.build_tree(['tree/bar']) |
|
269 |
tree.add('bar') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
270 |
tree.lock_tree_write() |
271 |
self.addCleanup(tree.unlock) |
|
|
0.16.93
by Aaron Bentley
Test shelving one file |
272 |
shelver = ExpectShelver(tree, tree.basis_tree(), file_list=['bar']) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
273 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
274 |
shelver.expect('Shelve adding file "bar"?', 0) |
275 |
shelver.expect('Shelve 1 change(s)?', 0) |
|
|
3990.4.2
by Daniel Watkins
Added test for help option. |
276 |
shelver.run() |
277 |
||
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
278 |
def test_shelve_destroy(self): |
|
4100.3.1
by Aaron Bentley
Implement shelve --destroy |
279 |
tree = self.create_shelvable_tree() |
280 |
shelver = shelf_ui.Shelver.from_args(sys.stdout, all=True, |
|
281 |
directory='tree', destroy=True) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
282 |
self.addCleanup(shelver.finalize) |
283 |
shelver.run() |
|
|
4100.3.1
by Aaron Bentley
Implement shelve --destroy |
284 |
self.assertIs(None, tree.get_shelf_manager().last_shelf()) |
285 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
286 |
||
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
287 |
@staticmethod
|
288 |
def shelve_all(tree, target_revision_id): |
|
289 |
tree.lock_write() |
|
290 |
try: |
|
291 |
target = tree.branch.repository.revision_tree(target_revision_id) |
|
292 |
shelver = shelf_ui.Shelver(tree, target, auto=True, |
|
293 |
auto_apply=True) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
294 |
try: |
295 |
shelver.run() |
|
296 |
finally: |
|
297 |
shelver.finalize() |
|
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
298 |
finally: |
299 |
tree.unlock() |
|
300 |
||
|
6011.1.3
by Vincent Ladeuil
Update the test name to avoid confusion. |
301 |
def test_shelve_old_root_preserved(self): |
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
302 |
tree1 = self.make_branch_and_tree('tree1') |
303 |
tree1.commit('add root') |
|
|
6011.1.6
by Vincent Ladeuil
Add news entry and further tweaks. |
304 |
tree1_root_id = tree1.get_root_id() |
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
305 |
tree2 = self.make_branch_and_tree('tree2') |
306 |
rev2 = tree2.commit('add root') |
|
|
6614.1.2
by Vincent Ladeuil
Fix assertNotEquals being deprecated by using assertNotEqual. |
307 |
self.assertNotEqual(tree1_root_id, tree2.get_root_id()) |
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
308 |
tree1.merge_from_branch(tree2.branch, |
309 |
from_revision=revision.NULL_REVISION) |
|
|
6011.1.6
by Vincent Ladeuil
Add news entry and further tweaks. |
310 |
tree1.commit('merging in tree2') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
311 |
self.assertEqual(tree1_root_id, tree1.get_root_id()) |
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
312 |
# This is essentially assertNotRaises(InconsistentDelta)
|
|
6011.1.3
by Vincent Ladeuil
Update the test name to avoid confusion. |
313 |
# With testtools 0.9.9, it can be rewritten as:
|
|
5954.4.11
by Aaron Bentley
Eschew testtools.testcase.ExpectedException from too-new testtools. |
314 |
# with ExpectedException(AssertionError,
|
315 |
# 'InconsistentDelta not raised'):
|
|
316 |
# with ExpectedException(errors.InconsistentDelta, ''):
|
|
317 |
# self.shelve_all(tree1, rev2)
|
|
318 |
e = self.assertRaises(AssertionError, self.assertRaises, |
|
319 |
errors.InconsistentDelta, self.shelve_all, tree1, |
|
320 |
rev2) |
|
321 |
self.assertContainsRe('InconsistentDelta not raised', str(e)) |
|
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
322 |
|
323 |
def test_shelve_split(self): |
|
324 |
outer_tree = self.make_branch_and_tree('outer') |
|
325 |
outer_tree.commit('Add root') |
|
326 |
inner_tree = self.make_branch_and_tree('outer/inner') |
|
327 |
rev2 = inner_tree.commit('Add root') |
|
328 |
outer_tree.subsume(inner_tree) |
|
|
4595.9.6
by Aaron Bentley
Update from review. |
329 |
# This is essentially assertNotRaises(ValueError).
|
330 |
# The ValueError is 'None is not a valid file id'.
|
|
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
331 |
self.expectFailure('Cannot shelve a join back to the inner tree.', |
332 |
self.assertRaises, AssertionError, |
|
333 |
self.assertRaises, ValueError, self.shelve_all, |
|
334 |
outer_tree, rev2) |
|
335 |
||
|
0.16.94
by Aaron Bentley
Add unshelve tests |
336 |
|
|
5954.2.3
by Aaron Bentley
Fix test duplication in TestApplyReporter |
337 |
class TestApplyReporter(ShelfTestCase): |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
338 |
|
339 |
def test_shelve_not_diff(self): |
|
340 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
341 |
tree.lock_tree_write() |
342 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
343 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
344 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
345 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
346 |
shelver.expect('Apply change?', 1) |
347 |
shelver.expect('Apply change?', 1) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
348 |
# No final shelving prompt because no changes were selected
|
349 |
shelver.run() |
|
350 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
351 |
||
352 |
def test_shelve_diff_no(self): |
|
353 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
354 |
tree.lock_tree_write() |
355 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
356 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
357 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
358 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
359 |
shelver.expect('Apply change?', 0) |
360 |
shelver.expect('Apply change?', 0) |
|
361 |
shelver.expect('Apply 2 change(s)?', 1) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
362 |
shelver.run() |
363 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
364 |
||
365 |
def test_shelve_diff(self): |
|
366 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
367 |
tree.lock_tree_write() |
368 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
369 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
370 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
371 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
372 |
shelver.expect('Apply change?', 0) |
373 |
shelver.expect('Apply change?', 0) |
|
374 |
shelver.expect('Apply 2 change(s)?', 0) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
375 |
shelver.run() |
376 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
377 |
||
378 |
def test_shelve_binary_change(self): |
|
379 |
tree = self.create_shelvable_tree() |
|
380 |
self.build_tree_contents([('tree/foo', '\x00')]) |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
381 |
tree.lock_tree_write() |
382 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
383 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
384 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
385 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
386 |
shelver.expect('Apply binary changes?', 0) |
387 |
shelver.expect('Apply 1 change(s)?', 0) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
388 |
shelver.run() |
389 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
390 |
||
391 |
def test_shelve_rename(self): |
|
392 |
tree = self.create_shelvable_tree() |
|
393 |
tree.rename_one('foo', 'bar') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
394 |
tree.lock_tree_write() |
395 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
396 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
397 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
398 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
399 |
shelver.expect('Rename "bar" => "foo"?', 0) |
400 |
shelver.expect('Apply change?', 0) |
|
401 |
shelver.expect('Apply change?', 0) |
|
402 |
shelver.expect('Apply 3 change(s)?', 0) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
403 |
shelver.run() |
404 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
405 |
||
406 |
def test_shelve_deletion(self): |
|
407 |
tree = self.create_shelvable_tree() |
|
408 |
os.unlink('tree/foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
409 |
tree.lock_tree_write() |
410 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
411 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
412 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
413 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
414 |
shelver.expect('Add file "foo"?', 0) |
415 |
shelver.expect('Apply 1 change(s)?', 0) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
416 |
shelver.run() |
417 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
418 |
||
419 |
def test_shelve_creation(self): |
|
420 |
tree = self.make_branch_and_tree('tree') |
|
421 |
tree.commit('add tree root') |
|
422 |
self.build_tree(['tree/foo']) |
|
423 |
tree.add('foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
424 |
tree.lock_tree_write() |
425 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
426 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
427 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
428 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
429 |
shelver.expect('Delete file "foo"?', 0) |
430 |
shelver.expect('Apply 1 change(s)?', 0) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
431 |
shelver.run() |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
432 |
self.assertPathDoesNotExist('tree/foo') |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
433 |
|
434 |
def test_shelve_kind_change(self): |
|
435 |
tree = self.create_shelvable_tree() |
|
436 |
os.unlink('tree/foo') |
|
437 |
os.mkdir('tree/foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
438 |
tree.lock_tree_write() |
439 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
440 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
441 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
442 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
443 |
shelver.expect('Change "foo" from directory to a file?', 0) |
444 |
shelver.expect('Apply 1 change(s)?', 0) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
445 |
|
446 |
def test_shelve_modify_target(self): |
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
447 |
self.requireFeature(features.SymlinkFeature) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
448 |
tree = self.create_shelvable_tree() |
449 |
os.symlink('bar', 'tree/baz') |
|
450 |
tree.add('baz', 'baz-id') |
|
451 |
tree.commit("Add symlink") |
|
452 |
os.unlink('tree/baz') |
|
453 |
os.symlink('vax', 'tree/baz') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
454 |
tree.lock_tree_write() |
455 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
456 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
457 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
458 |
self.addCleanup(shelver.finalize) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
459 |
shelver.expect('Change target of "baz" from "vax" to "bar"?', |
|
6182.2.8
by Benoît Pierre
Fix shelf_ui tests. |
460 |
0) |
|
6182.2.29
by Benoît Pierre
Avoid prompt duplication for shelf_ui tests. |
461 |
shelver.expect('Apply 1 change(s)?', 0) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
462 |
shelver.run() |
463 |
self.assertEqual('bar', os.readlink('tree/baz')) |
|
464 |
||
465 |
||
|
0.16.94
by Aaron Bentley
Add unshelve tests |
466 |
class TestUnshelver(tests.TestCaseWithTransport): |
467 |
||
468 |
def create_tree_with_shelf(self): |
|
469 |
tree = self.make_branch_and_tree('tree') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
470 |
tree.lock_write() |
471 |
try: |
|
472 |
self.build_tree_contents([('tree/foo', LINES_AJ)]) |
|
473 |
tree.add('foo', 'foo-id') |
|
474 |
tree.commit('added foo') |
|
475 |
self.build_tree_contents([('tree/foo', LINES_ZY)]) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
476 |
shelver = shelf_ui.Shelver(tree, tree.basis_tree(), |
477 |
auto_apply=True, auto=True) |
|
478 |
try: |
|
479 |
shelver.run() |
|
480 |
finally: |
|
481 |
shelver.finalize() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
482 |
finally: |
483 |
tree.unlock() |
|
|
0.16.94
by Aaron Bentley
Add unshelve tests |
484 |
return tree |
485 |
||
486 |
def test_unshelve(self): |
|
487 |
tree = self.create_tree_with_shelf() |
|
488 |
tree.lock_write() |
|
489 |
self.addCleanup(tree.unlock) |
|
490 |
manager = tree.get_shelf_manager() |
|
491 |
shelf_ui.Unshelver(tree, manager, 1, True, True, True).run() |
|
492 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
493 |
||
494 |
def test_unshelve_args(self): |
|
495 |
tree = self.create_tree_with_shelf() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
496 |
unshelver = shelf_ui.Unshelver.from_args(directory='tree') |
497 |
try: |
|
498 |
unshelver.run() |
|
499 |
finally: |
|
500 |
unshelver.tree.unlock() |
|
|
0.16.94
by Aaron Bentley
Add unshelve tests |
501 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
502 |
self.assertIs(None, tree.get_shelf_manager().last_shelf()) |
|
503 |
||
|
4902.1.5
by Guilherme Salgado
Re-add the test for Unshelver.dry_run and twek the test for preview |
504 |
def test_unshelve_args_dry_run(self): |
505 |
tree = self.create_tree_with_shelf() |
|
506 |
unshelver = shelf_ui.Unshelver.from_args(directory='tree', |
|
507 |
action='dry-run') |
|
508 |
try: |
|
509 |
unshelver.run() |
|
510 |
finally: |
|
511 |
unshelver.tree.unlock() |
|
512 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
513 |
self.assertEqual(1, tree.get_shelf_manager().last_shelf()) |
|
514 |
||
|
4902.1.3
by Guilherme Salgado
A few tweaks as per John's review |
515 |
def test_unshelve_args_preview(self): |
|
0.16.94
by Aaron Bentley
Add unshelve tests |
516 |
tree = self.create_tree_with_shelf() |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
517 |
write_diff_to = BytesIO() |
|
4902.1.3
by Guilherme Salgado
A few tweaks as per John's review |
518 |
unshelver = shelf_ui.Unshelver.from_args( |
519 |
directory='tree', action='preview', write_diff_to=write_diff_to) |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
520 |
try: |
521 |
unshelver.run() |
|
522 |
finally: |
|
523 |
unshelver.tree.unlock() |
|
|
4902.1.3
by Guilherme Salgado
A few tweaks as per John's review |
524 |
# The changes were not unshelved.
|
|
0.16.94
by Aaron Bentley
Add unshelve tests |
525 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
526 |
self.assertEqual(1, tree.get_shelf_manager().last_shelf()) |
|
|
4902.1.3
by Guilherme Salgado
A few tweaks as per John's review |
527 |
|
528 |
# But the diff was written to write_diff_to.
|
|
|
4902.1.5
by Guilherme Salgado
Re-add the test for Unshelver.dry_run and twek the test for preview |
529 |
diff = write_diff_to.getvalue() |
|
4902.1.6
by Guilherme Salgado
Tweak the text to check to assert the meat of the diff is what we expect, instead of just checking it matches some regexps |
530 |
expected = dedent("""\ |
531 |
@@ -1,4 +1,4 @@
|
|
532 |
-a
|
|
533 |
+z
|
|
534 |
b
|
|
535 |
c
|
|
536 |
d
|
|
537 |
@@ -7,4 +7,4 @@
|
|
538 |
g
|
|
539 |
h
|
|
540 |
i
|
|
541 |
-j
|
|
542 |
+y
|
|
543 |
||
544 |
""") |
|
545 |
self.assertEqualDiff(expected, diff[-len(expected):]) |
|
|
0.16.94
by Aaron Bentley
Add unshelve tests |
546 |
|
547 |
def test_unshelve_args_delete_only(self): |
|
548 |
tree = self.make_branch_and_tree('tree') |
|
549 |
manager = tree.get_shelf_manager() |
|
550 |
shelf_file = manager.new_shelf()[1] |
|
551 |
try: |
|
552 |
shelf_file.write('garbage') |
|
553 |
finally: |
|
554 |
shelf_file.close() |
|
555 |
unshelver = shelf_ui.Unshelver.from_args(directory='tree', |
|
556 |
action='delete-only') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
557 |
try: |
558 |
unshelver.run() |
|
559 |
finally: |
|
560 |
unshelver.tree.unlock() |
|
|
0.16.94
by Aaron Bentley
Add unshelve tests |
561 |
self.assertIs(None, manager.last_shelf()) |
|
3990.2.1
by Daniel Watkins
Added test for unshelve being passed an invalid shelf_id. |
562 |
|
563 |
def test_unshelve_args_invalid_shelf_id(self): |
|
564 |
tree = self.make_branch_and_tree('tree') |
|
565 |
manager = tree.get_shelf_manager() |
|
566 |
shelf_file = manager.new_shelf()[1] |
|
567 |
try: |
|
568 |
shelf_file.write('garbage') |
|
569 |
finally: |
|
570 |
shelf_file.close() |
|
571 |
self.assertRaises(errors.InvalidShelfId, |
|
|
3999.1.1
by Ian Clatworthy
Improve shelf documentation & fix backtrace (Daniel Watkins) |
572 |
shelf_ui.Unshelver.from_args, directory='tree', |
573 |
action='delete-only', shelf_id='foo') |
|
|
4899.2.1
by Neil Martinsen-Burrell
add beter feedback from the unshelve command |
574 |
|
|
4899.2.2
by Neil Martinsen-Burrell
tests updated to use the appropriate TestCase... class for scripts |
575 |
|
576 |
class TestUnshelveScripts(TestUnshelver, |
|
577 |
script.TestCaseWithTransportAndScript): |
|
578 |
||
|
4899.2.1
by Neil Martinsen-Burrell
add beter feedback from the unshelve command |
579 |
def test_unshelve_messages_keep(self): |
580 |
self.create_tree_with_shelf() |
|
|
4899.2.2
by Neil Martinsen-Burrell
tests updated to use the appropriate TestCase... class for scripts |
581 |
self.run_script(""" |
|
4899.2.1
by Neil Martinsen-Burrell
add beter feedback from the unshelve command |
582 |
$ cd tree
|
|
6622.1.33
by Jelmer Vernooij
Fix more tests (all?) |
583 |
$ brz unshelve --keep
|
|
4899.2.1
by Neil Martinsen-Burrell
add beter feedback from the unshelve command |
584 |
2>Using changes with id "1".
|
585 |
2> M foo
|
|
586 |
2>All changes applied successfully.
|
|
587 |
""") |
|
588 |
||
589 |
def test_unshelve_messages_delete(self): |
|
590 |
self.create_tree_with_shelf() |
|
|
4899.2.2
by Neil Martinsen-Burrell
tests updated to use the appropriate TestCase... class for scripts |
591 |
self.run_script(""" |
|
4899.2.1
by Neil Martinsen-Burrell
add beter feedback from the unshelve command |
592 |
$ cd tree
|
|
6622.1.33
by Jelmer Vernooij
Fix more tests (all?) |
593 |
$ brz unshelve --delete-only
|
|
4899.2.1
by Neil Martinsen-Burrell
add beter feedback from the unshelve command |
594 |
2>Deleted changes with id "1".
|
595 |
""") |
|
596 |
||
597 |
def test_unshelve_messages_apply(self): |
|
598 |
self.create_tree_with_shelf() |
|
|
4899.2.2
by Neil Martinsen-Burrell
tests updated to use the appropriate TestCase... class for scripts |
599 |
self.run_script(""" |
|
4899.2.1
by Neil Martinsen-Burrell
add beter feedback from the unshelve command |
600 |
$ cd tree
|
|
6622.1.33
by Jelmer Vernooij
Fix more tests (all?) |
601 |
$ brz unshelve --apply
|
|
4899.2.1
by Neil Martinsen-Burrell
add beter feedback from the unshelve command |
602 |
2>Using changes with id "1".
|
603 |
2> M foo
|
|
604 |
2>All changes applied successfully.
|
|
605 |
2>Deleted changes with id "1".
|
|
606 |
""") |
|
607 |
||
608 |
def test_unshelve_messages_dry_run(self): |
|
609 |
self.create_tree_with_shelf() |
|
|
4899.2.2
by Neil Martinsen-Burrell
tests updated to use the appropriate TestCase... class for scripts |
610 |
self.run_script(""" |
|
4899.2.1
by Neil Martinsen-Burrell
add beter feedback from the unshelve command |
611 |
$ cd tree
|
|
6622.1.33
by Jelmer Vernooij
Fix more tests (all?) |
612 |
$ brz unshelve --dry-run
|
|
4899.2.1
by Neil Martinsen-Burrell
add beter feedback from the unshelve command |
613 |
2>Using changes with id "1".
|
614 |
2> M foo
|
|
615 |
""") |