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