/brz/remove-bazaar

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