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): |
|
75 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
76 |
tree.lock_tree_write() |
77 |
self.addCleanup(tree.unlock) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
78 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
79 |
self.addCleanup(shelver.finalize) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
80 |
e = self.assertRaises(AssertionError, shelver.run) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
81 |
self.assertEqual('Unexpected prompt: Shelve? [yNfq?]', str(e)) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
82 |
|
83 |
def test_wrong_prompt_failure(self): |
|
84 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
85 |
tree.lock_tree_write() |
86 |
self.addCleanup(tree.unlock) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
87 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
88 |
self.addCleanup(shelver.finalize) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
89 |
shelver.expect('foo', 'y') |
90 |
e = self.assertRaises(AssertionError, shelver.run) |
|
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
91 |
self.assertEqual('Wrong prompt: Shelve? [yNfq?]', str(e)) |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
92 |
|
93 |
def test_shelve_not_diff(self): |
|
94 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
95 |
tree.lock_tree_write() |
96 |
self.addCleanup(tree.unlock) |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
97 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
98 |
self.addCleanup(shelver.finalize) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
99 |
shelver.expect('Shelve? [yNfq?]', 'n') |
100 |
shelver.expect('Shelve? [yNfq?]', 'n') |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
101 |
# No final shelving prompt because no changes were selected
|
102 |
shelver.run() |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
103 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
104 |
|
105 |
def test_shelve_diff_no(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) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
111 |
shelver.expect('Shelve? [yNfq?]', 'y') |
112 |
shelver.expect('Shelve? [yNfq?]', 'y') |
|
113 |
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'n') |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
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(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) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
123 |
shelver.expect('Shelve? [yNfq?]', 'y') |
124 |
shelver.expect('Shelve? [yNfq?]', 'y') |
|
125 |
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'y') |
|
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
126 |
shelver.run() |
127 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
128 |
||
129 |
def test_shelve_one_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.90
by Aaron Bentley
Handle shelving multiple diff hunks |
133 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
134 |
self.addCleanup(shelver.finalize) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
135 |
shelver.expect('Shelve? [yNfq?]', 'y') |
136 |
shelver.expect('Shelve? [yNfq?]', 'n') |
|
137 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
138 |
shelver.run() |
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
139 |
self.assertFileEqual(LINES_AY, 'tree/foo') |
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
140 |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
141 |
def test_shelve_binary_change(self): |
142 |
tree = self.create_shelvable_tree() |
|
143 |
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) |
144 |
tree.lock_tree_write() |
145 |
self.addCleanup(tree.unlock) |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
146 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
147 |
self.addCleanup(shelver.finalize) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
148 |
shelver.expect('Shelve binary changes? [yNfq?]', 'y') |
149 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
150 |
shelver.run() |
151 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
152 |
||
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
153 |
def test_shelve_rename(self): |
154 |
tree = self.create_shelvable_tree() |
|
155 |
tree.rename_one('foo', 'bar') |
|
|
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.89
by Aaron Bentley
Add tests for Shelver |
158 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
159 |
self.addCleanup(shelver.finalize) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
160 |
shelver.expect('Shelve renaming "foo" => "bar"? [yNfq?]', 'y') |
161 |
shelver.expect('Shelve? [yNfq?]', 'y') |
|
162 |
shelver.expect('Shelve? [yNfq?]', 'y') |
|
163 |
shelver.expect('Shelve 3 change(s)? [yNfq?]', 'y') |
|
|
0.16.89
by Aaron Bentley
Add tests for Shelver |
164 |
shelver.run() |
|
0.16.90
by Aaron Bentley
Handle shelving multiple diff hunks |
165 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
0.16.91
by Aaron Bentley
Test finish and quit |
166 |
|
167 |
def test_shelve_deletion(self): |
|
168 |
tree = self.create_shelvable_tree() |
|
169 |
os.unlink('tree/foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
170 |
tree.lock_tree_write() |
171 |
self.addCleanup(tree.unlock) |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
172 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
173 |
self.addCleanup(shelver.finalize) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
174 |
shelver.expect('Shelve removing file "foo"? [yNfq?]', 'y') |
175 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
176 |
shelver.run() |
177 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
178 |
||
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
179 |
def test_shelve_creation(self): |
180 |
tree = self.make_branch_and_tree('tree') |
|
181 |
tree.commit('add tree root') |
|
182 |
self.build_tree(['tree/foo']) |
|
183 |
tree.add('foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
184 |
tree.lock_tree_write() |
185 |
self.addCleanup(tree.unlock) |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
186 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
187 |
self.addCleanup(shelver.finalize) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
188 |
shelver.expect('Shelve adding file "foo"? [yNfq?]', 'y') |
189 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
190 |
shelver.run() |
191 |
self.failIfExists('tree/foo') |
|
192 |
||
193 |
def test_shelve_kind_change(self): |
|
194 |
tree = self.create_shelvable_tree() |
|
195 |
os.unlink('tree/foo') |
|
196 |
os.mkdir('tree/foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
197 |
tree.lock_tree_write() |
198 |
self.addCleanup(tree.unlock) |
|
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
199 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
200 |
self.addCleanup(shelver.finalize) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
201 |
shelver.expect('Shelve changing "foo" from file to directory? [yNfq?]', |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
202 |
'y') |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
203 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
204 |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
205 |
def test_shelve_modify_target(self): |
|
4526.6.12
by Aaron Bentley
Updates from review. |
206 |
self.requireFeature(tests.SymlinkFeature) |
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
207 |
tree = self.create_shelvable_tree() |
208 |
os.symlink('bar', 'tree/baz') |
|
209 |
tree.add('baz', 'baz-id') |
|
210 |
tree.commit("Add symlink") |
|
211 |
os.unlink('tree/baz') |
|
212 |
os.symlink('vax', 'tree/baz') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
213 |
tree.lock_tree_write() |
214 |
self.addCleanup(tree.unlock) |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
215 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
216 |
self.addCleanup(shelver.finalize) |
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
217 |
shelver.expect('Shelve changing target of "baz" from "bar" to ' |
218 |
'"vax"? [yNfq?]', 'y') |
|
219 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
220 |
shelver.run() |
|
221 |
self.assertEqual('bar', os.readlink('tree/baz')) |
|
222 |
||
|
0.16.91
by Aaron Bentley
Test finish and quit |
223 |
def test_shelve_finish(self): |
224 |
tree = self.create_shelvable_tree() |
|
|
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) |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
227 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
228 |
self.addCleanup(shelver.finalize) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
229 |
shelver.expect('Shelve? [yNfq?]', 'f') |
230 |
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'y') |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
231 |
shelver.run() |
232 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
233 |
||
234 |
def test_shelve_quit(self): |
|
235 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
236 |
tree.lock_tree_write() |
237 |
self.addCleanup(tree.unlock) |
|
|
0.16.91
by Aaron Bentley
Test finish and quit |
238 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
239 |
self.addCleanup(shelver.finalize) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
240 |
shelver.expect('Shelve? [yNfq?]', 'q') |
|
0.16.103
by Aaron Bentley
raise UserAbort instead of doing sys.exit |
241 |
self.assertRaises(errors.UserAbort, shelver.run) |
|
0.16.91
by Aaron Bentley
Test finish and quit |
242 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
243 |
|
244 |
def test_shelve_all(self): |
|
245 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
246 |
shelver = ExpectShelver.from_args(sys.stdout, all=True, |
247 |
directory='tree') |
|
248 |
try: |
|
249 |
shelver.run() |
|
250 |
finally: |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
251 |
shelver.finalize() |
|
0.16.92
by Aaron Bentley
Test kind, add, binary, --all |
252 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
0.16.93
by Aaron Bentley
Test shelving one file |
253 |
|
254 |
def test_shelve_filename(self): |
|
255 |
tree = self.create_shelvable_tree() |
|
256 |
self.build_tree(['tree/bar']) |
|
257 |
tree.add('bar') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
258 |
tree.lock_tree_write() |
259 |
self.addCleanup(tree.unlock) |
|
|
0.16.93
by Aaron Bentley
Test shelving one file |
260 |
shelver = ExpectShelver(tree, tree.basis_tree(), file_list=['bar']) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
261 |
self.addCleanup(shelver.finalize) |
|
3990.4.1
by Daniel Watkins
Changed all shelve tests to expect a '?'. |
262 |
shelver.expect('Shelve adding file "bar"? [yNfq?]', 'y') |
263 |
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y') |
|
|
0.16.93
by Aaron Bentley
Test shelving one file |
264 |
shelver.run() |
|
0.16.94
by Aaron Bentley
Add unshelve tests |
265 |
|
|
3990.4.2
by Daniel Watkins
Added test for help option. |
266 |
def test_shelve_help(self): |
267 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
268 |
tree.lock_tree_write() |
269 |
self.addCleanup(tree.unlock) |
|
|
3990.4.2
by Daniel Watkins
Added test for help option. |
270 |
shelver = ExpectShelver(tree, tree.basis_tree()) |
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
271 |
self.addCleanup(shelver.finalize) |
|
3990.4.2
by Daniel Watkins
Added test for help option. |
272 |
shelver.expect('Shelve? [yNfq?]', '?') |
273 |
shelver.expect('Shelve? [(y)es, (N)o, (f)inish, or (q)uit]', 'f') |
|
274 |
shelver.expect('Shelve 2 change(s)? [yNfq?]', 'y') |
|
275 |
shelver.run() |
|
276 |
||
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
277 |
def test_shelve_destroy(self): |
|
4100.3.1
by Aaron Bentley
Implement shelve --destroy |
278 |
tree = self.create_shelvable_tree() |
279 |
shelver = shelf_ui.Shelver.from_args(sys.stdout, all=True, |
|
280 |
directory='tree', destroy=True) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
281 |
self.addCleanup(shelver.finalize) |
282 |
shelver.run() |
|
|
4100.3.1
by Aaron Bentley
Implement shelve --destroy |
283 |
self.assertIs(None, tree.get_shelf_manager().last_shelf()) |
284 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
285 |
||
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
286 |
@staticmethod
|
287 |
def shelve_all(tree, target_revision_id): |
|
288 |
tree.lock_write() |
|
289 |
try: |
|
290 |
target = tree.branch.repository.revision_tree(target_revision_id) |
|
291 |
shelver = shelf_ui.Shelver(tree, target, auto=True, |
|
292 |
auto_apply=True) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
293 |
try: |
294 |
shelver.run() |
|
295 |
finally: |
|
296 |
shelver.finalize() |
|
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
297 |
finally: |
298 |
tree.unlock() |
|
299 |
||
300 |
def test_shelve_old_root_deleted(self): |
|
301 |
tree1 = self.make_branch_and_tree('tree1') |
|
302 |
tree1.commit('add root') |
|
303 |
tree2 = self.make_branch_and_tree('tree2') |
|
304 |
rev2 = tree2.commit('add root') |
|
305 |
tree1.merge_from_branch(tree2.branch, |
|
306 |
from_revision=revision.NULL_REVISION) |
|
307 |
tree1.commit('Replaced root entry') |
|
308 |
# This is essentially assertNotRaises(InconsistentDelta)
|
|
309 |
self.expectFailure('Cannot shelve replacing a root entry', |
|
310 |
self.assertRaises, AssertionError, |
|
311 |
self.assertRaises, errors.InconsistentDelta, |
|
312 |
self.shelve_all, tree1, rev2) |
|
313 |
||
314 |
def test_shelve_split(self): |
|
315 |
outer_tree = self.make_branch_and_tree('outer') |
|
316 |
outer_tree.commit('Add root') |
|
317 |
inner_tree = self.make_branch_and_tree('outer/inner') |
|
318 |
rev2 = inner_tree.commit('Add root') |
|
319 |
outer_tree.subsume(inner_tree) |
|
|
4595.9.6
by Aaron Bentley
Update from review. |
320 |
# This is essentially assertNotRaises(ValueError).
|
321 |
# The ValueError is 'None is not a valid file id'.
|
|
|
4595.9.5
by Aaron Bentley
Add expected failures for shelving root changes. |
322 |
self.expectFailure('Cannot shelve a join back to the inner tree.', |
323 |
self.assertRaises, AssertionError, |
|
324 |
self.assertRaises, ValueError, self.shelve_all, |
|
325 |
outer_tree, rev2) |
|
326 |
||
|
0.16.94
by Aaron Bentley
Add unshelve tests |
327 |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
328 |
class TestApplyReporter(TestShelver): |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
329 |
|
330 |
def test_shelve_not_diff(self): |
|
331 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
332 |
tree.lock_tree_write() |
333 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
334 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
335 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
336 |
self.addCleanup(shelver.finalize) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
337 |
shelver.expect('Apply change? [yNfq?]', 'n') |
338 |
shelver.expect('Apply change? [yNfq?]', 'n') |
|
339 |
# No final shelving prompt because no changes were selected
|
|
340 |
shelver.run() |
|
341 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
342 |
||
343 |
def test_shelve_diff_no(self): |
|
344 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
345 |
tree.lock_tree_write() |
346 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
347 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
348 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
349 |
self.addCleanup(shelver.finalize) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
350 |
shelver.expect('Apply change? [yNfq?]', 'y') |
351 |
shelver.expect('Apply change? [yNfq?]', 'y') |
|
352 |
shelver.expect('Apply 2 change(s)? [yNfq?]', 'n') |
|
353 |
shelver.run() |
|
354 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
355 |
||
356 |
def test_shelve_diff(self): |
|
357 |
tree = self.create_shelvable_tree() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
358 |
tree.lock_tree_write() |
359 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
360 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
361 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
362 |
self.addCleanup(shelver.finalize) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
363 |
shelver.expect('Apply change? [yNfq?]', 'y') |
364 |
shelver.expect('Apply change? [yNfq?]', 'y') |
|
365 |
shelver.expect('Apply 2 change(s)? [yNfq?]', 'y') |
|
366 |
shelver.run() |
|
367 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
368 |
||
369 |
def test_shelve_binary_change(self): |
|
370 |
tree = self.create_shelvable_tree() |
|
371 |
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) |
372 |
tree.lock_tree_write() |
373 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
374 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
375 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
376 |
self.addCleanup(shelver.finalize) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
377 |
shelver.expect('Apply binary changes? [yNfq?]', 'y') |
378 |
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y') |
|
379 |
shelver.run() |
|
380 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
381 |
||
382 |
def test_shelve_rename(self): |
|
383 |
tree = self.create_shelvable_tree() |
|
384 |
tree.rename_one('foo', 'bar') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
385 |
tree.lock_tree_write() |
386 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
387 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
388 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
389 |
self.addCleanup(shelver.finalize) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
390 |
shelver.expect('Rename "bar" => "foo"? [yNfq?]', 'y') |
391 |
shelver.expect('Apply change? [yNfq?]', 'y') |
|
392 |
shelver.expect('Apply change? [yNfq?]', 'y') |
|
393 |
shelver.expect('Apply 3 change(s)? [yNfq?]', 'y') |
|
394 |
shelver.run() |
|
395 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
396 |
||
397 |
def test_shelve_deletion(self): |
|
398 |
tree = self.create_shelvable_tree() |
|
399 |
os.unlink('tree/foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
400 |
tree.lock_tree_write() |
401 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
402 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
403 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
404 |
self.addCleanup(shelver.finalize) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
405 |
shelver.expect('Add file "foo"? [yNfq?]', 'y') |
406 |
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y') |
|
407 |
shelver.run() |
|
408 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
|
409 |
||
410 |
def test_shelve_creation(self): |
|
411 |
tree = self.make_branch_and_tree('tree') |
|
412 |
tree.commit('add tree root') |
|
413 |
self.build_tree(['tree/foo']) |
|
414 |
tree.add('foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
415 |
tree.lock_tree_write() |
416 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
417 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
418 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
419 |
self.addCleanup(shelver.finalize) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
420 |
shelver.expect('Delete file "foo"? [yNfq?]', 'y') |
421 |
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y') |
|
422 |
shelver.run() |
|
423 |
self.failIfExists('tree/foo') |
|
424 |
||
425 |
def test_shelve_kind_change(self): |
|
426 |
tree = self.create_shelvable_tree() |
|
427 |
os.unlink('tree/foo') |
|
428 |
os.mkdir('tree/foo') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
429 |
tree.lock_tree_write() |
430 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
431 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
432 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
433 |
self.addCleanup(shelver.finalize) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
434 |
shelver.expect('Change "foo" from directory to a file? [yNfq?]', 'y') |
435 |
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y') |
|
436 |
||
437 |
def test_shelve_modify_target(self): |
|
|
4526.6.12
by Aaron Bentley
Updates from review. |
438 |
self.requireFeature(tests.SymlinkFeature) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
439 |
tree = self.create_shelvable_tree() |
440 |
os.symlink('bar', 'tree/baz') |
|
441 |
tree.add('baz', 'baz-id') |
|
442 |
tree.commit("Add symlink") |
|
443 |
os.unlink('tree/baz') |
|
444 |
os.symlink('vax', 'tree/baz') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
445 |
tree.lock_tree_write() |
446 |
self.addCleanup(tree.unlock) |
|
|
4526.7.1
by Aaron Bentley
Make vocabulary part of reporter. |
447 |
shelver = ExpectShelver(tree, tree.basis_tree(), |
448 |
reporter=shelf_ui.ApplyReporter()) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
449 |
self.addCleanup(shelver.finalize) |
|
4526.6.1
by Aaron Bentley
Reverse the way changes are described by Shelver. |
450 |
shelver.expect('Change target of "baz" from "vax" to "bar"? [yNfq?]', |
451 |
'y') |
|
452 |
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y') |
|
453 |
shelver.run() |
|
454 |
self.assertEqual('bar', os.readlink('tree/baz')) |
|
455 |
||
456 |
||
|
0.16.94
by Aaron Bentley
Add unshelve tests |
457 |
class TestUnshelver(tests.TestCaseWithTransport): |
458 |
||
459 |
def create_tree_with_shelf(self): |
|
460 |
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) |
461 |
tree.lock_write() |
462 |
try: |
|
463 |
self.build_tree_contents([('tree/foo', LINES_AJ)]) |
|
464 |
tree.add('foo', 'foo-id') |
|
465 |
tree.commit('added foo') |
|
466 |
self.build_tree_contents([('tree/foo', LINES_ZY)]) |
|
|
4603.1.17
by Aaron Bentley
Fix shelf_ui tests to finalize. |
467 |
shelver = shelf_ui.Shelver(tree, tree.basis_tree(), |
468 |
auto_apply=True, auto=True) |
|
469 |
try: |
|
470 |
shelver.run() |
|
471 |
finally: |
|
472 |
shelver.finalize() |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
473 |
finally: |
474 |
tree.unlock() |
|
|
0.16.94
by Aaron Bentley
Add unshelve tests |
475 |
return tree |
476 |
||
477 |
def test_unshelve(self): |
|
478 |
tree = self.create_tree_with_shelf() |
|
479 |
tree.lock_write() |
|
480 |
self.addCleanup(tree.unlock) |
|
481 |
manager = tree.get_shelf_manager() |
|
482 |
shelf_ui.Unshelver(tree, manager, 1, True, True, True).run() |
|
483 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
|
484 |
||
485 |
def test_unshelve_args(self): |
|
486 |
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) |
487 |
unshelver = shelf_ui.Unshelver.from_args(directory='tree') |
488 |
try: |
|
489 |
unshelver.run() |
|
490 |
finally: |
|
491 |
unshelver.tree.unlock() |
|
|
0.16.94
by Aaron Bentley
Add unshelve tests |
492 |
self.assertFileEqual(LINES_ZY, 'tree/foo') |
493 |
self.assertIs(None, tree.get_shelf_manager().last_shelf()) |
|
494 |
||
495 |
def test_unshelve_args_dry_run(self): |
|
496 |
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) |
497 |
unshelver = shelf_ui.Unshelver.from_args(directory='tree', |
498 |
action='dry-run') |
|
499 |
try: |
|
500 |
unshelver.run() |
|
501 |
finally: |
|
502 |
unshelver.tree.unlock() |
|
|
0.16.94
by Aaron Bentley
Add unshelve tests |
503 |
self.assertFileEqual(LINES_AJ, 'tree/foo') |
504 |
self.assertEqual(1, tree.get_shelf_manager().last_shelf()) |
|
505 |
||
506 |
def test_unshelve_args_delete_only(self): |
|
507 |
tree = self.make_branch_and_tree('tree') |
|
508 |
manager = tree.get_shelf_manager() |
|
509 |
shelf_file = manager.new_shelf()[1] |
|
510 |
try: |
|
511 |
shelf_file.write('garbage') |
|
512 |
finally: |
|
513 |
shelf_file.close() |
|
514 |
unshelver = shelf_ui.Unshelver.from_args(directory='tree', |
|
515 |
action='delete-only') |
|
|
4595.13.2
by Alexander Belchenko
[cherrypick revno 4650 from bzr.dev] Fix shelve on windows. (Robert Collins, #305006) |
516 |
try: |
517 |
unshelver.run() |
|
518 |
finally: |
|
519 |
unshelver.tree.unlock() |
|
|
0.16.94
by Aaron Bentley
Add unshelve tests |
520 |
self.assertIs(None, manager.last_shelf()) |
|
3990.2.1
by Daniel Watkins
Added test for unshelve being passed an invalid shelf_id. |
521 |
|
522 |
def test_unshelve_args_invalid_shelf_id(self): |
|
523 |
tree = self.make_branch_and_tree('tree') |
|
524 |
manager = tree.get_shelf_manager() |
|
525 |
shelf_file = manager.new_shelf()[1] |
|
526 |
try: |
|
527 |
shelf_file.write('garbage') |
|
528 |
finally: |
|
529 |
shelf_file.close() |
|
530 |
self.assertRaises(errors.InvalidShelfId, |
|
|
3999.1.1
by Ian Clatworthy
Improve shelf documentation & fix backtrace (Daniel Watkins) |
531 |
shelf_ui.Unshelver.from_args, directory='tree', |
532 |
action='delete-only', shelf_id='foo') |