bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
1 |
# Copyright (C) 2008 Canonical Ltd
|
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 |
||
18 |
from cStringIO import StringIO |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
19 |
import os |
|
0.16.108
by Aaron Bentley
Shelf supports multiple diff writers. |
20 |
import sys |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
21 |
|
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
22 |
from bzrlib import ( |
23 |
errors, |
|
24 |
shelf_ui, |
|
25 |
revision, |
|
26 |
tests, |
|
27 |
)
|
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
28 |
|
29 |
||
30 |
class ExpectShelver(shelf_ui.Shelver): |
|
31 |
"""A variant of Shelver that intercepts console activity, for testing.""" |
|
32 |
||
|
4100.3.4
by Aaron Bentley
Clean up signatures |
33 |
def __init__(self, work_tree, target_tree, diff_writer=None, |
34 |
auto=False, auto_apply=False, file_list=None, message=None, |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
35 |
destroy=False, reporter=None): |
|
0.16.108
by Aaron Bentley
Shelf supports multiple diff writers. |
36 |
shelf_ui.Shelver.__init__(self, work_tree, target_tree, diff_writer, |
|
4100.3.4
by Aaron Bentley
Clean up signatures |
37 |
auto, auto_apply, file_list, message, |
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
38 |
destroy, reporter=reporter) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
39 |
self.expected = [] |
40 |
self.diff_writer = StringIO() |
|
41 |
||
42 |
def expect(self, prompt, response): |
|
43 |
self.expected.append((prompt, response)) |
|
44 |
||
45 |
def prompt(self, message): |
|
46 |
try: |
|
47 |
prompt, response = self.expected.pop(0) |
|
48 |
except IndexError: |
|
49 |
raise AssertionError('Unexpected prompt: %s' % message) |
|
50 |
if prompt != message: |
|
51 |
raise AssertionError('Wrong prompt: %s' % message) |
|
52 |
return response |
|
53 |
||
54 |
||
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
55 |
LINES_AJ = 'a\nb\nc\nd\ne\nf\ng\nh\ni\nj\n' |
56 |
||
57 |
||
58 |
LINES_ZY = 'z\nb\nc\nd\ne\nf\ng\nh\ni\ny\n' |
|
59 |
||
60 |
||
61 |
LINES_AY = 'a\nb\nc\nd\ne\nf\ng\nh\ni\ny\n' |
|
62 |
||
63 |
||
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
64 |
class TestShelver(tests.TestCaseWithTransport): |
65 |
||
66 |
def create_shelvable_tree(self): |
|
67 |
tree = self.make_branch_and_tree('tree') |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
68 |
self.build_tree_contents([('tree/foo', LINES_AJ)]) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
69 |
tree.add('foo', 'foo-id') |
70 |
tree.commit('added foo') |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
71 |
self.build_tree_contents([('tree/foo', LINES_ZY)]) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
72 |
return tree |
73 |
||
74 |
def test_unexpected_prompt_failure(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
75 |
self.thisFailsStrictLockCheck() |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
76 |
tree = self.create_shelvable_tree() |
77 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
78 |
e = self.assertRaises(AssertionError, shelver.run) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
79 |
self.assertEqual('Unexpected prompt: Shelve? [yNfq?]', str(e)) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
80 |
|
81 |
def test_wrong_prompt_failure(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
82 |
self.thisFailsStrictLockCheck() |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
83 |
tree = self.create_shelvable_tree() |
84 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
85 |
shelver.expect('foo', 'y') |
|
86 |
e = self.assertRaises(AssertionError, shelver.run) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
87 |
self.assertEqual('Wrong prompt: Shelve? [yNfq?]', str(e)) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
88 |
|
89 |
def test_shelve_not_diff(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
90 |
self.thisFailsStrictLockCheck() |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
91 |
tree = self.create_shelvable_tree() |
92 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
93 |
shelver.expect('Shelve? [yNfq?]', 'n') |
94 |
shelver.expect('Shelve? [yNfq?]', 'n') |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
95 |
# No final shelving prompt because no changes were selected
|
96 |
shelver.run() |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
97 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
98 |
|
99 |
def test_shelve_diff_no(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
100 |
self.thisFailsStrictLockCheck() |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
101 |
tree = self.create_shelvable_tree() |
102 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
103 |
shelver.expect('Shelve? [yNfq?]', 'y') |
104 |
shelver.expect('Shelve? [yNfq?]', 'y') |
|
105 |
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'n') |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
106 |
shelver.run() |
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
107 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
108 |
|
109 |
def test_shelve_diff(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
110 |
self.thisFailsStrictLockCheck() |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
111 |
tree = self.create_shelvable_tree() |
112 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
113 |
shelver.expect('Shelve? [yNfq?]', 'y') |
114 |
shelver.expect('Shelve? [yNfq?]', 'y') |
|
115 |
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'y') |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
116 |
shelver.run() |
117 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
118 |
||
119 |
def test_shelve_one_diff(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
120 |
self.thisFailsStrictLockCheck() |
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
121 |
tree = self.create_shelvable_tree() |
122 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
123 |
shelver.expect('Shelve? [yNfq?]', 'y') |
124 |
shelver.expect('Shelve? [yNfq?]', 'n') |
|
125 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
|
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_AY, 'tree/foo') |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
128 |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
129 |
def test_shelve_binary_change(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
130 |
self.thisFailsStrictLockCheck() |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
131 |
tree = self.create_shelvable_tree() |
132 |
self.build_tree_contents([('tree/foo', '\x00')]) |
|
133 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
134 |
shelver.expect('Shelve binary changes? [yNfq?]', 'y') |
135 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
136 |
shelver.run() |
137 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
138 |
||
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
139 |
def test_shelve_rename(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
140 |
self.thisFailsStrictLockCheck() |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
141 |
tree = self.create_shelvable_tree() |
142 |
tree.rename_one('foo', 'bar') |
|
143 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
144 |
shelver.expect('Shelve renaming "foo" => "bar"? [yNfq?]', 'y') |
145 |
shelver.expect('Shelve? [yNfq?]', 'y') |
|
146 |
shelver.expect('Shelve? [yNfq?]', 'y') |
|
147 |
shelver.expect('Shelve 3 change(s)? [yNfq?]', 'y') |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
148 |
shelver.run() |
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
149 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
0.16.91
by Aaron Bentley
Test finish and quit |
150 |
|
151 |
def test_shelve_deletion(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
152 |
self.thisFailsStrictLockCheck() |
|
0.16.91
by Aaron Bentley
Test finish and quit |
153 |
tree = self.create_shelvable_tree() |
154 |
os.unlink('tree/foo') |
|
155 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
156 |
shelver.expect('Shelve removing file "foo"? [yNfq?]', 'y') |
157 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
158 |
shelver.run() |
159 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
160 |
||
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
161 |
def test_shelve_creation(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
162 |
self.thisFailsStrictLockCheck() |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
163 |
tree = self.make_branch_and_tree('tree') |
164 |
tree.commit('add tree root') |
|
165 |
self.build_tree(['tree/foo']) |
|
166 |
tree.add('foo') |
|
167 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
168 |
shelver.expect('Shelve adding file "foo"? [yNfq?]', 'y') |
169 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
170 |
shelver.run() |
171 |
self.failIfExists('tree/foo') |
|
172 |
||
173 |
def test_shelve_kind_change(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
174 |
self.thisFailsStrictLockCheck() |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
175 |
tree = self.create_shelvable_tree() |
176 |
os.unlink('tree/foo') |
|
177 |
os.mkdir('tree/foo') |
|
178 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
179 |
shelver.expect('Shelve changing "foo" from file to directory? [yNfq?]', |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
180 |
'y') |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
181 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
182 |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
183 |
def test_shelve_modify_target(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
184 |
self.thisFailsStrictLockCheck() |
|
4526.6.12
by Aaron Bentley
Updates from review. |
185 |
self.requireFeature(tests.SymlinkFeature) |
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
186 |
tree = self.create_shelvable_tree() |
187 |
os.symlink('bar', 'tree/baz') |
|
188 |
tree.add('baz', 'baz-id') |
|
189 |
tree.commit("Add symlink") |
|
190 |
os.unlink('tree/baz') |
|
191 |
os.symlink('vax', 'tree/baz') |
|
192 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
193 |
shelver.expect('Shelve changing target of "baz" from "bar" to ' |
|
194 |
'"vax"? [yNfq?]', 'y') |
|
195 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
196 |
shelver.run() |
|
197 |
self.assertEqual('bar', os.readlink('tree/baz')) |
|
198 |
||
|
0.16.91
by Aaron Bentley
Test finish and quit |
199 |
def test_shelve_finish(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
200 |
self.thisFailsStrictLockCheck() |
|
0.16.91
by Aaron Bentley
Test finish and quit |
201 |
tree = self.create_shelvable_tree() |
202 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
203 |
shelver.expect('Shelve? [yNfq?]', 'f') |
204 |
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'y') |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
205 |
shelver.run() |
206 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
207 |
||
208 |
def test_shelve_quit(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
209 |
self.thisFailsStrictLockCheck() |
|
0.16.91
by Aaron Bentley
Test finish and quit |
210 |
tree = self.create_shelvable_tree() |
211 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
212 |
shelver.expect('Shelve? [yNfq?]', 'q') |
|
0.16.103
by Aaron Bentley
raise UserAbort instead of doing sys.exit |
213 |
self.assertRaises(errors.UserAbort, shelver.run) |
|
0.16.91
by Aaron Bentley
Test finish and quit |
214 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
215 |
|
216 |
def test_shelve_all(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
217 |
self.thisFailsStrictLockCheck() |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
218 |
tree = self.create_shelvable_tree() |
|
0.16.108
by Aaron Bentley
Shelf supports multiple diff writers. |
219 |
ExpectShelver.from_args(sys.stdout, all=True, directory='tree').run() |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
220 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
0.16.93
by Aaron Bentley
Test shelving one file |
221 |
|
222 |
def test_shelve_filename(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
223 |
self.thisFailsStrictLockCheck() |
|
0.16.93
by Aaron Bentley
Test shelving one file |
224 |
tree = self.create_shelvable_tree() |
225 |
self.build_tree(['tree/bar']) |
|
226 |
tree.add('bar') |
|
227 |
shelver = ExpectShelver(tree, tree.basis_tree(), file_list=['bar']) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
228 |
shelver.expect('Shelve adding file "bar"? [yNfq?]', 'y') |
229 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
|
0.16.93
by Aaron Bentley
Test shelving one file |
230 |
shelver.run() |
|
0.16.94
by Aaron Bentley
Add unshelve tests |
231 |
|
|
3990.4.2
by Daniel Watkins
Added test for help option. |
232 |
def test_shelve_help(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
233 |
self.thisFailsStrictLockCheck() |
|
3990.4.2
by Daniel Watkins
Added test for help option. |
234 |
tree = self.create_shelvable_tree() |
235 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
236 |
shelver.expect('Shelve? [yNfq?]', '?') |
|
237 |
shelver.expect('Shelve? [(y)es, (N)o, (f)inish, or (q)uit]', 'f') |
|
238 |
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'y') |
|
239 |
shelver.run() |
|
240 |
||
|
4100.3.1
by Aaron Bentley
Implement shelve --destroy |
241 |
def test_shelve_distroy(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
242 |
self.thisFailsStrictLockCheck() |
|
4100.3.1
by Aaron Bentley
Implement shelve --destroy |
243 |
tree = self.create_shelvable_tree() |
244 |
shelver = shelf_ui.Shelver.from_args(sys.stdout, all=True, |
|
245 |
directory='tree', destroy=True) |
|
246 |
shelver.run() |
|
247 |
self.assertIs(None, tree.get_shelf_manager().last_shelf()) |
|
248 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
249 |
||
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
250 |
@staticmethod
|
251 |
def shelve_all(tree, target_revision_id): |
|
252 |
tree.lock_write() |
|
253 |
try: |
|
254 |
target = tree.branch.repository.revision_tree(target_revision_id) |
|
255 |
shelver = shelf_ui.Shelver(tree, target, auto=True, |
|
256 |
auto_apply=True) |
|
257 |
shelver.run() |
|
258 |
finally: |
|
259 |
tree.unlock() |
|
260 |
||
261 |
def test_shelve_old_root_deleted(self): |
|
262 |
tree1 = self.make_branch_and_tree('tree1') |
|
263 |
tree1.commit('add root') |
|
264 |
tree2 = self.make_branch_and_tree('tree2') |
|
265 |
rev2 = tree2.commit('add root') |
|
266 |
tree1.merge_from_branch(tree2.branch, |
|
267 |
from_revision=revision.NULL_REVISION) |
|
268 |
tree1.commit('Replaced root entry') |
|
269 |
# This is essentially assertNotRaises(InconsistentDelta)
|
|
270 |
self.expectFailure('Cannot shelve replacing a root entry', |
|
271 |
self.assertRaises, AssertionError, |
|
272 |
self.assertRaises, errors.InconsistentDelta, |
|
273 |
self.shelve_all, tree1, rev2) |
|
274 |
||
275 |
def test_shelve_split(self): |
|
276 |
outer_tree = self.make_branch_and_tree('outer') |
|
277 |
outer_tree.commit('Add root') |
|
278 |
inner_tree = self.make_branch_and_tree('outer/inner') |
|
279 |
rev2 = inner_tree.commit('Add root') |
|
280 |
outer_tree.subsume(inner_tree) |
|
|
4595.9.6
by Aaron Bentley
Update from review. |
281 |
# This is essentially assertNotRaises(ValueError).
|
282 |
# The ValueError is 'None is not a valid file id'.
|
|
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
283 |
self.expectFailure('Cannot shelve a join back to the inner tree.', |
284 |
self.assertRaises, AssertionError, |
|
285 |
self.assertRaises, ValueError, self.shelve_all, |
|
286 |
outer_tree, rev2) |
|
287 |
||
|
0.16.94
by Aaron Bentley
Add unshelve tests |
288 |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
289 |
class TestApplyReporter(TestShelver): |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
290 |
|
291 |
def test_shelve_not_diff(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
292 |
self.thisFailsStrictLockCheck() |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
293 |
tree = self.create_shelvable_tree() |
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
294 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
295 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
296 |
shelver.expect('Apply change? [yNfq?]', 'n') |
297 |
shelver.expect('Apply change? [yNfq?]', 'n') |
|
298 |
# No final shelving prompt because no changes were selected
|
|
299 |
shelver.run() |
|
300 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
301 |
||
302 |
def test_shelve_diff_no(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
303 |
self.thisFailsStrictLockCheck() |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
304 |
tree = self.create_shelvable_tree() |
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
305 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
306 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
307 |
shelver.expect('Apply change? [yNfq?]', 'y') |
308 |
shelver.expect('Apply change? [yNfq?]', 'y') |
|
309 |
shelver.expect('Apply 2 change(s)? [yNfq?]', 'n') |
|
310 |
shelver.run() |
|
311 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
312 |
||
313 |
def test_shelve_diff(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
314 |
self.thisFailsStrictLockCheck() |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
315 |
tree = self.create_shelvable_tree() |
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
316 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
317 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
318 |
shelver.expect('Apply change? [yNfq?]', 'y') |
319 |
shelver.expect('Apply change? [yNfq?]', 'y') |
|
320 |
shelver.expect('Apply 2 change(s)? [yNfq?]', 'y') |
|
321 |
shelver.run() |
|
322 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
323 |
||
324 |
def test_shelve_binary_change(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
325 |
self.thisFailsStrictLockCheck() |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
326 |
tree = self.create_shelvable_tree() |
327 |
self.build_tree_contents([('tree/foo', '\x00')]) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
328 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
329 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
330 |
shelver.expect('Apply binary changes? [yNfq?]', 'y') |
331 |
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y') |
|
332 |
shelver.run() |
|
333 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
334 |
||
335 |
def test_shelve_rename(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
336 |
self.thisFailsStrictLockCheck() |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
337 |
tree = self.create_shelvable_tree() |
338 |
tree.rename_one('foo', 'bar') |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
339 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
340 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
341 |
shelver.expect('Rename "bar" => "foo"? [yNfq?]', 'y') |
342 |
shelver.expect('Apply change? [yNfq?]', 'y') |
|
343 |
shelver.expect('Apply change? [yNfq?]', 'y') |
|
344 |
shelver.expect('Apply 3 change(s)? [yNfq?]', 'y') |
|
345 |
shelver.run() |
|
346 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
347 |
||
348 |
def test_shelve_deletion(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
349 |
self.thisFailsStrictLockCheck() |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
350 |
tree = self.create_shelvable_tree() |
351 |
os.unlink('tree/foo') |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
352 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
353 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
354 |
shelver.expect('Add file "foo"? [yNfq?]', 'y') |
355 |
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y') |
|
356 |
shelver.run() |
|
357 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
358 |
||
359 |
def test_shelve_creation(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
360 |
self.thisFailsStrictLockCheck() |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
361 |
tree = self.make_branch_and_tree('tree') |
362 |
tree.commit('add tree root') |
|
363 |
self.build_tree(['tree/foo']) |
|
364 |
tree.add('foo') |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
365 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
366 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
367 |
shelver.expect('Delete file "foo"? [yNfq?]', 'y') |
368 |
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y') |
|
369 |
shelver.run() |
|
370 |
self.failIfExists('tree/foo') |
|
371 |
||
372 |
def test_shelve_kind_change(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
373 |
self.thisFailsStrictLockCheck() |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
374 |
tree = self.create_shelvable_tree() |
375 |
os.unlink('tree/foo') |
|
376 |
os.mkdir('tree/foo') |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
377 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
378 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
379 |
shelver.expect('Change "foo" from directory to a file? [yNfq?]', 'y') |
380 |
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y') |
|
381 |
||
382 |
def test_shelve_modify_target(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
383 |
self.thisFailsStrictLockCheck() |
|
4526.6.12
by Aaron Bentley
Updates from review. |
384 |
self.requireFeature(tests.SymlinkFeature) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
385 |
tree = self.create_shelvable_tree() |
386 |
os.symlink('bar', 'tree/baz') |
|
387 |
tree.add('baz', 'baz-id') |
|
388 |
tree.commit("Add symlink") |
|
389 |
os.unlink('tree/baz') |
|
390 |
os.symlink('vax', 'tree/baz') |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
391 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
392 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
393 |
shelver.expect('Change target of "baz" from "vax" to "bar"? [yNfq?]', |
394 |
'y') |
|
395 |
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y') |
|
396 |
shelver.run() |
|
397 |
self.assertEqual('bar', os.readlink('tree/baz')) |
|
398 |
||
399 |
||
|
0.16.94
by Aaron Bentley
Add unshelve tests |
400 |
class TestUnshelver(tests.TestCaseWithTransport): |
401 |
||
402 |
def create_tree_with_shelf(self): |
|
403 |
tree = self.make_branch_and_tree('tree') |
|
404 |
self.build_tree_contents([('tree/foo', LINES_AJ)]) |
|
405 |
tree.add('foo', 'foo-id') |
|
406 |
tree.commit('added foo') |
|
407 |
self.build_tree_contents([('tree/foo', LINES_ZY)]) |
|
|
0.16.97
by Aaron Bentley
Turn diff_file and text_differ into instance variables. |
408 |
shelf_ui.Shelver(tree, tree.basis_tree(), auto_apply=True, |
|
0.16.94
by Aaron Bentley
Add unshelve tests |
409 |
auto=True).run() |
410 |
return tree |
|
411 |
||
412 |
def test_unshelve(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
413 |
self.thisFailsStrictLockCheck() |
|
0.16.94
by Aaron Bentley
Add unshelve tests |
414 |
tree = self.create_tree_with_shelf() |
415 |
tree.lock_write() |
|
416 |
self.addCleanup(tree.unlock) |
|
417 |
manager = tree.get_shelf_manager() |
|
418 |
shelf_ui.Unshelver(tree, manager, 1, True, True, True).run() |
|
419 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
420 |
||
421 |
def test_unshelve_args(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
422 |
self.thisFailsStrictLockCheck() |
|
0.16.94
by Aaron Bentley
Add unshelve tests |
423 |
tree = self.create_tree_with_shelf() |
424 |
shelf_ui.Unshelver.from_args(directory='tree').run() |
|
425 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
426 |
self.assertIs(None, tree.get_shelf_manager().last_shelf()) |
|
427 |
||
428 |
def test_unshelve_args_dry_run(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
429 |
self.thisFailsStrictLockCheck() |
|
0.16.94
by Aaron Bentley
Add unshelve tests |
430 |
tree = self.create_tree_with_shelf() |
431 |
shelf_ui.Unshelver.from_args(directory='tree', action='dry-run').run() |
|
432 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
433 |
self.assertEqual(1, tree.get_shelf_manager().last_shelf()) |
|
434 |
||
435 |
def test_unshelve_args_delete_only(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
436 |
self.thisFailsStrictLockCheck() |
|
0.16.94
by Aaron Bentley
Add unshelve tests |
437 |
tree = self.make_branch_and_tree('tree') |
438 |
manager = tree.get_shelf_manager() |
|
439 |
shelf_file = manager.new_shelf()[1] |
|
440 |
try: |
|
441 |
shelf_file.write('garbage') |
|
442 |
finally: |
|
443 |
shelf_file.close() |
|
444 |
unshelver = shelf_ui.Unshelver.from_args(directory='tree', |
|
445 |
action='delete-only') |
|
446 |
unshelver.run() |
|
447 |
self.assertIs(None, manager.last_shelf()) |
|
|
3990.2.1
by Daniel Watkins
Added test for unshelve being passed an invalid shelf_id. |
448 |
|
449 |
def test_unshelve_args_invalid_shelf_id(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
450 |
self.thisFailsStrictLockCheck() |
|
3990.2.1
by Daniel Watkins
Added test for unshelve being passed an invalid shelf_id. |
451 |
tree = self.make_branch_and_tree('tree') |
452 |
manager = tree.get_shelf_manager() |
|
453 |
shelf_file = manager.new_shelf()[1] |
|
454 |
try: |
|
455 |
shelf_file.write('garbage') |
|
456 |
finally: |
|
457 |
shelf_file.close() |
|
458 |
self.assertRaises(errors.InvalidShelfId, |
|
|
3999.1.1
by Ian Clatworthy
Improve shelf documentation & fix backtrace (Daniel Watkins) |
459 |
shelf_ui.Unshelver.from_args, directory='tree', |
460 |
action='delete-only', shelf_id='foo') |