75
32
self.__test_loop(10)
77
34
def __test_loop(self, count):
78
self.tree = self.make_branch_and_tree('.')
79
self.__create_and_add_test_file()
80
for counter in range(count):
35
tree = self.make_branch_and_tree('.')
36
self.__create_and_add_test_file(tree)
81
41
# Modify the test file
82
# write in binary mode because on win32 line-endings should be
84
f = file('test_file', 'wb')
85
f.write(self.MODIFIED)
90
self.tree.lock_write()
92
new_date = _patch_header_date(self.tree,
93
self.tree.inventory.path2id('test_file'), 'test_file')
42
file('test_file', 'w').write(self.MODIFIED)
44
# Check the diff is right
45
self.assertEqual(self.capture('diff', retcode=1),
46
self.DIFF_HEADER + self.DIFF_1 + '\n')
97
48
# Shelve the changes
98
self.run_bzr('shelve --all', retcode=0)
49
self.run_bzr('shelve', '--all', retcode=0)
100
51
# Make sure there is no diff anymore
101
self.assertEqual(self.run_bzr('diff', retcode=0)[0], '')
52
self.assertEqual(self.capture('diff', retcode=0), '')
103
54
# Make sure the file is actually back the way it was
104
55
self.assertEqual(file('test_file').read(), self.ORIGINAL)
106
self._check_shelf('00', new_date=new_date)
57
# Check the shelf is right
58
shelf = open(os.path.join(tree.branch.base,
59
'.shelf/shelves/default/00')).read()
60
shelf = shelf[shelf.index('\n') + 1:] # skip the message
61
self.assertEqual(shelf, self.DIFF_1)
109
self.run_bzr('unshelve --all', retcode=0)
64
self.run_bzr('unshelve', '--all', retcode=0)
66
# Check the diff is right again
67
self.assertEqual(self.capture('diff', retcode=1),
68
self.DIFF_HEADER + self.DIFF_1 + '\n')
113
70
# Check the shelved patch was backed up
114
self._check_shelf('00~', new_date=new_date)
71
shelf = open(os.path.join(tree.branch.base,
72
'.shelf/shelves/default/00~')).read()
73
shelf = shelf[shelf.index('\n') + 1:] # skip the message
74
self.assertEqual(shelf, self.DIFF_1)
116
76
# Make sure the file is back the way it should be
117
77
self.assertEqual(file('test_file').read(), self.MODIFIED)
119
79
def test_shelf_nothing_to_shelve(self):
121
self.tree = self.make_branch_and_tree('.')
122
self.__create_and_add_test_file()
81
tree = self.make_branch_and_tree('.')
82
self.__create_and_add_test_file(tree)
124
84
# Shelve the changes
125
self.run_bzr('shelve --all', retcode=3)
85
self.run_bzr('shelve', '--all', retcode=3)
127
if os.path.exists(os.path.join(self.tree.branch.base,
87
if os.path.exists(os.path.join(tree.branch.base,
128
88
'.shelf/shelves/default/00')):
129
89
self.fail("Shelf exists, but it shouldn't")
131
def __create_and_add_test_file(self, filename='test_file'):
132
# write in binary mode because on win32 line-endings should be LF
133
f = open(filename, 'wb')
91
def __create_and_add_test_file(self, tree, filename='test_file'):
92
f = open(filename, 'w')
134
93
f.write(self.ORIGINAL)
136
self.tree.add(self.tree.relpath(os.path.join(os.getcwd(), filename)))
137
self.tree.commit(message='add %s' % filename)
95
tree.add(tree.relpath(os.path.join(os.getcwd(), filename)))
96
tree.commit(message='add %s' % filename)
139
98
def test_shelf_with_revision(self):
140
self.tree = self.make_branch_and_tree('.')
99
tree = self.make_branch_and_tree('.')
142
self.__create_and_add_test_file()
101
self.__create_and_add_test_file(tree)
144
103
# Modify the test file and commit it
145
104
self.build_tree_contents([('test_file', self.MODIFIED)])
146
self.tree.commit(message='update test_file')
105
tree.commit(message='update test_file')
148
107
# Shelve the changes
149
self.run_bzr('shelve --all -r 1', retcode=0)
108
self.run_bzr('shelve', '--all', '-r', '1', retcode=0)
151
self._check_diff(self.DIFF_2)
110
# Check the diff is right
111
self.assertEqual(self.capture('diff', retcode=1),
112
self.DIFF_HEADER + self.DIFF_2 + '\n')
153
114
# Make sure the file is the way it should be
154
115
self.assertEqual(file('test_file').read(), self.ORIGINAL)
157
self.run_bzr('unshelve --all', retcode=0)
118
self.run_bzr('unshelve', '--all', retcode=0)
159
120
# Make sure the file is back the way it should be
160
121
self.assertEqual(file('test_file').read(), self.MODIFIED)
162
123
def test_shelf_with_two_revisions(self):
163
self.tree = self.make_branch_and_tree('.')
124
tree = self.make_branch_and_tree('.')
165
stdout, stderr = self.run_bzr('shelve --all -r 1..2', retcode=None)
126
cmd = 'shelve --all -r 1..2'
127
(stdout, stderr) = self.run_bzr_captured(cmd.split(), retcode=None)
167
129
self.assertEqual(stderr.split('\n')[0],
168
130
'bzr: ERROR: shelve only accepts a single revision parameter.')
170
132
def test_shelf_show_basic(self):
171
self.tree = self.make_branch_and_tree('.')
172
self.__create_and_add_test_file()
173
self.__test_show(self.tree, '00')
133
tree = self.make_branch_and_tree('.')
134
self.__create_and_add_test_file(tree)
135
self.__test_show(tree, '00')
175
137
def __test_show(self, tree, patch):
176
138
# Modify the test file
177
139
self.build_tree_contents([('test_file', 'patch %s\n' % patch)])
179
141
# Shelve the changes
180
self.run_bzr('shelve --all', retcode=0)
142
self.run_bzr('shelve', '--all', retcode=0)
182
144
# Make sure there is no diff anymore
183
self.assertEqual(self.run_bzr('diff', retcode=0)[0], '')
145
self.assertEqual(self.capture('diff', retcode=0), '')
185
147
# Check the shelf is right
186
shelf = open(os.path.join(self.tree.basedir,
148
shelf = open(os.path.join(tree.branch.base,
187
149
'.shelf/shelves/default', patch)).read()
188
150
self.assertTrue('patch %s' % patch in shelf)
190
152
# Check the shown output is right
191
shown = self.run_bzr('shelf show %s' % patch, retcode=0)[0]
153
shown = self.capture('shelf show %s' % patch, retcode=0)
192
154
self.assertEqual(shown, shelf)
194
156
def test_shelf_show_multi(self):
195
self.tree = self.make_branch_and_tree('.')
196
self.__create_and_add_test_file()
197
self.__test_show(self.tree, '00')
198
self.__test_show(self.tree, '01')
199
self.__test_show(self.tree, '02')
157
tree = self.make_branch_and_tree('.')
158
self.__create_and_add_test_file(tree)
159
self.__test_show(tree, '00')
160
self.__test_show(tree, '01')
161
self.__test_show(tree, '02')
201
163
# Now check we can show a previously shelved patch
202
shelf = open(os.path.join(self.tree.basedir,
164
shelf = open(os.path.join(tree.branch.base,
203
165
'.shelf/shelves/default/00')).read()
204
166
self.assertTrue('patch 00' in shelf)
206
168
# Check the shown output is right
207
shown = self.run_bzr('shelf show 00', retcode=0)[0]
208
self.assertEqual(shown, shelf)
210
def test_shelf_show_unspecified(self):
211
self.tree = self.make_branch_and_tree('.')
212
self.__create_and_add_test_file()
213
self.__test_show(self.tree, '00')
214
self.__test_show(self.tree, '01')
215
self.__test_show(self.tree, '02')
217
# Check that not specifying at patch gets us the most recent
218
shelf = open(os.path.join(self.tree.basedir,
219
'.shelf/shelves/default/02')).read()
220
self.assertTrue('patch 02' in shelf)
222
# Check the shown output is right
223
shown = self.run_bzr('shelf show', retcode=0)[0]
169
shown = self.capture('shelf show 00', retcode=0)
224
170
self.assertEqual(shown, shelf)
226
172
def test_shelf_show_with_no_patch(self):
227
self.tree = self.make_branch_and_tree('.')
228
stderr = self.run_bzr('shelf show 00', retcode=None)[1]
173
tree = self.make_branch_and_tree('.')
174
stderr = self.run_bzr_captured(['shelf', 'show', '00'], retcode=None)[1]
229
175
self.assertTrue("Patch '00' doesn't exist on shelf default!" in stderr)
231
177
def test_shelf_unshelve_failure(self):
232
self.tree = self.make_branch_and_tree('.')
178
tree = self.make_branch_and_tree('.')
234
self.__create_and_add_test_file()
180
self.__create_and_add_test_file(tree)
236
182
# Modify the test file
237
183
file('test_file', 'w').write(self.MODIFIED)
239
185
# Shelve the changes
240
self.run_bzr('shelve --all', retcode=0)
186
self.run_bzr('shelve', '--all', retcode=0)
242
188
# Write an unapplyable patch into the shelf
243
shelf = open(os.path.join(self.tree.basedir,
189
shelf = open(os.path.join(tree.branch.base,
244
190
'.shelf/shelves/default/00'), 'w')
245
191
shelf.write(self.DIFF_2)
248
194
# Unshelve, should fail
249
self.run_bzr('unshelve --all', retcode=3)
195
self.run_bzr('unshelve', '--all', retcode=3)
251
197
# Make sure the patch is still there, eventhough it's broken
252
shelf = open(os.path.join(self.tree.basedir,
198
shelf = open(os.path.join(tree.branch.base,
253
199
'.shelf/shelves/default/00')).read()
254
200
self.assertEqual(shelf, self.DIFF_2)
256
202
# Working tree should be unchanged
257
diff = self.run_bzr('diff', retcode=0)[0]
203
diff = self.capture('diff', retcode=0)
258
204
self.assertEqual(diff, '')
260
206
def test_shelf_unshelve_failure_two_hunks(self):
261
self.tree = self.make_branch_and_tree('.')
207
tree = self.make_branch_and_tree('.')
263
self.__create_and_add_test_file()
264
self.__create_and_add_test_file(filename='test_file2')
209
self.__create_and_add_test_file(tree)
210
self.__create_and_add_test_file(tree, filename='test_file2')
266
212
# Modify the test files
267
213
file('test_file', 'w').write(self.MODIFIED)
268
214
file('test_file2', 'w').write(self.MODIFIED)
270
216
# Shelve the changes
271
self.run_bzr('shelve --all', retcode=0)
217
self.run_bzr('shelve', '--all', retcode=0)
273
219
# Put the changes to test_file back, the shelved patch won't apply now
274
220
file('test_file', 'w').write(self.MODIFIED)
275
self.tree.commit(message='screw up test_file')
221
tree.commit(message='screw up test_file')
277
223
# Unshelve, should fail
278
self.run_bzr('unshelve --all', retcode=3)
224
self.run_bzr('unshelve', '--all', retcode=3)
280
226
# Working tree should be unchanged
281
diff = self.run_bzr('diff', retcode=0)[0]
227
diff = self.capture('diff', retcode=0)
282
228
self.assertEqual(diff, '')
284
230
# Force should succeed and modify test_file2, but leave shelf
285
self.run_bzr('unshelve --force --all', retcode=0)
231
self.run_bzr('unshelve', '--force', '--all', retcode=0)
286
232
self.assertEqual(open('test_file2').read(), self.MODIFIED)
287
233
self.assertTrue(os.path.exists('.shelf/shelves/default/00'))
289
235
def test_shelf_after_unshelve(self):
290
self.tree = self.make_branch_and_tree('.')
236
tree = self.make_branch_and_tree('.')
292
self.__create_and_add_test_file()
293
self.__create_and_add_test_file(filename='test_file2')
238
self.__create_and_add_test_file(tree)
239
self.__create_and_add_test_file(tree, filename='test_file2')
295
241
# Modify the test files
296
242
file('test_file', 'w').write(self.MODIFIED)
297
243
file('test_file2', 'w').write(self.MODIFIED)
299
245
# Shelve the changes
300
self.run_bzr('shelve --all test_file', retcode=0)
301
self.run_bzr('shelve --all test_file2', retcode=0)
246
self.run_bzr('shelve', '--all', 'test_file', retcode=0)
247
self.run_bzr('shelve', '--all', 'test_file2', retcode=0)
304
self.run_bzr('unshelve --all', retcode=0)
250
self.run_bzr('unshelve', '--all', retcode=0)
306
252
# We should now have 00 and 01~
307
253
self.assertTrue(os.path.exists('.shelf/shelves/default/00'))
308
254
self.assertTrue(os.path.exists('.shelf/shelves/default/01~'))
311
lines = self.run_bzr('shelf ls', retcode=0)[0].split('\n')
257
list = self.capture('shelf ls', retcode=0).split('\n')
313
259
self.assertFalse(line.startswith(' 01'))
315
261
# Unshelve, if unshelve is confused by the backup it will fail
316
self.run_bzr('unshelve --all', retcode=0)
262
self.run_bzr('unshelve', '--all', retcode=0)
318
264
def test_shelf_delete(self):
319
self.tree = self.make_branch_and_tree('.')
320
self.tree.lock_write()
322
self.__create_and_add_test_file()
323
self.__create_and_add_test_file(filename='test_file2')
325
# Modify the test files
326
# write in binary mode because on win32 line-endings should be LF
327
f = file('test_file', 'wb')
328
f.write(self.MODIFIED)
330
f = file('test_file2', 'wb')
331
f.write(self.MODIFIED)
333
new_date = _patch_header_date(self.tree,
334
self.tree.inventory.path2id('test_file'), 'test_file')
265
tree = self.make_branch_and_tree('.')
267
self.__create_and_add_test_file(tree)
268
self.__create_and_add_test_file(tree, filename='test_file2')
270
# Modify the test files
271
file('test_file', 'w').write(self.MODIFIED)
272
file('test_file2', 'w').write(self.MODIFIED)
338
274
# Shelve the changes
339
self.run_bzr('shelve --all test_file', retcode=0)
340
self.run_bzr('shelve --all test_file2', retcode=0)
342
self._check_shelf('00', new_date=new_date)
275
self.run_bzr('shelve', '--all', 'test_file', retcode=0)
276
self.run_bzr('shelve', '--all', 'test_file2', retcode=0)
345
self.run_bzr('shelf delete 00', retcode=0)
279
self.run_bzr('shelf', 'delete', '00', retcode=0)
347
# We should now have 01 but not 00, but we should have 00~
281
# We should now have 01 but not 00
348
282
self.assertFalse(os.path.exists('.shelf/shelves/default/00'))
349
self.assertTrue(os.path.exists('.shelf/shelves/default/00~'))
350
283
self.assertTrue(os.path.exists('.shelf/shelves/default/01'))
352
# Check the backup is right
353
self._check_shelf('00~', new_date=new_date)
356
lines = self.run_bzr('shelf ls', retcode=0)[0].split('\n')
286
list = self.capture('shelf ls', retcode=0).split('\n')
358
288
self.assertFalse(line.startswith(' 00'))
360
290
# Unshelve should unshelve 01
361
self.run_bzr('unshelve --all', retcode=0)
291
self.run_bzr('unshelve', '--all', retcode=0)
362
292
self.assertEqual(file('test_file2').read(), self.MODIFIED)
364
294
def test_shelf_gaps(self):
365
self.tree = self.make_branch_and_tree('.')
366
self.__create_and_add_test_file()
367
file('test_file', 'w').write(self.MODIFIED)
368
self.run_bzr('shelve --all test_file', retcode=0)
369
file('test_file', 'w').write(self.MODIFIED)
370
self.run_bzr('shelve --all test_file', retcode=0)
295
tree = self.make_branch_and_tree('.')
296
self.__create_and_add_test_file(tree)
297
file('test_file', 'w').write(self.MODIFIED)
298
self.run_bzr('shelve', '--all', 'test_file', retcode=0)
299
file('test_file', 'w').write(self.MODIFIED)
300
self.run_bzr('shelve', '--all', 'test_file', retcode=0)
372
302
# Now delete 00, leaving 01, next shelve should go into 02
373
self.run_bzr('shelf delete 0', retcode=0)
303
self.run_bzr('shelf', 'delete', '0', retcode=0)
374
304
self.assertFalse(os.path.exists('.shelf/shelves/default/00'))
375
305
self.assertFalse(os.path.exists('.shelf/shelves/default/02'))
376
306
file('test_file', 'w').write(self.MODIFIED)
377
self.run_bzr('shelve --all test_file', retcode=0)
307
self.run_bzr('shelve', '--all', 'test_file', retcode=0)
378
308
self.assertFalse(os.path.exists('.shelf/shelves/default/00'))
379
309
self.assertTrue(os.path.exists('.shelf/shelves/default/02'))
381
311
def test_shelf_upgrade(self):
382
self.tree = self.make_branch_and_tree('.')
312
tree = self.make_branch_and_tree('.')
384
self.__create_and_add_test_file()
314
self.__create_and_add_test_file(tree)
386
316
# Modify then shelve, so we're not upgrading to 00, just for kicks
387
317
file('test_file', 'w').write(self.MODIFIED)
388
self.run_bzr('shelve --all test_file', retcode=0)
318
self.run_bzr('shelve', '--all', 'test_file', retcode=0)
390
320
open('.bzr-shelf', 'w').write('First old shelf')
391
321
open('.bzr-shelf-1', 'w').write('Second old shelf')
417
347
self.assertFalse(os.path.exists('.bzr-shelf-3'))
419
349
# Shelve should work now
420
self.run_bzr('shelve --all', retcode=0)
422
def test_shelf_p1_patch(self):
423
self.tree = self.make_branch_and_tree('.')
425
self.__create_and_add_test_file()
350
self.run_bzr('shelve', '--all', retcode=0)
352
def test_shelf_p0_patch(self):
353
tree = self.make_branch_and_tree('.')
355
self.__create_and_add_test_file(tree)
427
357
# Run a benign shelf command to setup .shelf for us
428
self.run_bzr('shelf ls', retcode=0)
358
self.run_bzr('shelf', 'ls', retcode=0)
430
old_tree = self.tree.basis_tree()
432
self.tree.lock_read()
434
old_date = _patch_header_date(old_tree,
435
old_tree.inventory.path2id('test_file'),
437
new_date = _patch_header_date(self.tree,
438
self.tree.inventory.path2id('test_file'), 'test_file')
442
360
# Fake a -p0 shelved patch
443
diff = self.DIFF_1 % { 'filename' : 'test_file', 'old_date': old_date,
444
'new_date' : new_date}
445
diff = diff.replace('--- ', '--- a/')
446
diff = diff.replace('+++ ', '+++ b/')
362
diff = diff.replace('a/', '')
363
diff = diff.replace('b/', '')
447
364
open('.shelf/shelves/default/00', 'w').write(diff)
449
366
# This should work
450
self.run_bzr('unshelve --all', retcode=0)
367
self.run_bzr('unshelve', '--all', retcode=0)
369
# Check the diff is right
370
self.assertEqual(self.capture('diff', retcode=1),
371
self.DIFF_HEADER + self.DIFF_1 + '\n')
454
373
def test_shelf_shelve_in_subdir(self):
455
self.tree = self.make_branch_and_tree('.')
459
self.tree.add(subdir)
462
self.__create_and_add_test_file()
374
tree = self.make_branch_and_tree('.')
376
self.__create_and_add_test_file(tree)
464
378
# Modify the test file
465
# write in binary mode because on win32 line-endings should be LF
466
f = file('test_file', 'wb')
467
f.write(self.MODIFIED)
379
file('test_file', 'w').write(self.MODIFIED)
470
381
# Shelve the changes
471
self.run_bzr('shelve --all', retcode=0)
382
self.run_bzr('shelve', '--all', retcode=0)
473
384
# Working tree should be unchanged
474
diff = self.run_bzr('diff', retcode=0)[0]
385
diff = self.capture('diff', retcode=0)
475
386
self.assertEqual(diff, '')
477
388
# Unshelve, should succeed
478
self.run_bzr('unshelve --all', retcode=0)
480
self._check_diff(filename='subdir/test_file')
482
# Make sure relative filenames work ok
483
self.run_bzr('shelve test_file --all', retcode=0)
485
def test_shelf_shelf_bogus_subcommand(self):
486
self.tree = self.make_branch_and_tree('.')
487
self.run_bzr('shelf foo', retcode=3) # <- retcode == 3
489
def test_shelf_OOO_unshelve(self):
490
self.tree = self.make_branch_and_tree('.')
492
for i in range(1, 5):
493
self.__create_and_add_test_file(filename='test_file%d' % i)
495
# Modify the test files
496
for i in range(1, 5):
497
file('test_file%d' % i, 'w').write(self.MODIFIED)
500
for i in range(1, 5):
501
self.run_bzr(['shelve', '--all', 'test_file%d' % i], retcode=0)
503
# Check shelving worked
504
for i in range(1, 5):
505
self.assertEqual(file('test_file%d' % i).read(), self.ORIGINAL)
507
# We should now have 00-03
508
for i in range(0, 4):
509
self.assertTrue(os.path.exists('.shelf/shelves/default/0%d' % i))
512
self.run_bzr('unshelve --all 00', retcode=0)
513
self.assertEqual(file('test_file1').read(), self.MODIFIED)
516
lines = self.run_bzr('shelf ls', retcode=0)[0].split('\n')
518
self.assertFalse(line.startswith(' 00'))
520
# Check we can reshelve once we've unshelved out of order, should be 04
521
self.assertFalse(os.path.exists('.shelf/shelves/default/04'))
522
self.run_bzr('shelve --all')
523
self.assertTrue(os.path.exists('.shelf/shelves/default/04'))
526
text = self.run_bzr('shelf ls', retcode=0)[0]
527
for line in text.split('\n'):
528
self.assertFalse(line.startswith(' 00'))
530
# We now have 01,02,03,04
532
self.run_bzr('unshelve --all 02', retcode=0)
533
self.assertEqual(file('test_file3').read(), self.MODIFIED)
535
# Unshelve the default, this is the reshelved 00, hence modifies file 1
536
self.run_bzr('unshelve --all', retcode=0)
537
self.assertEqual(file('test_file1').read(), self.MODIFIED)
539
def test_shelf_switch_basic(self):
540
self.tree = self.make_branch_and_tree('.')
541
self.__create_and_add_test_file()
543
# This should go to "default"
544
file('test_file', 'w').write(self.MODIFIED)
545
self.run_bzr('shelve --all test_file', retcode=0)
548
self.run_bzr('shelf switch other', retcode=0)
549
file('test_file', 'w').write(self.MODIFIED)
550
self.run_bzr('shelve --all test_file', retcode=0)
553
self.assertTrue(os.path.exists('.shelf/shelves/default/00'))
554
self.assertFalse(os.path.exists('.shelf/shelves/default/01'))
555
self.assertTrue(os.path.exists('.shelf/shelves/other/00'))
558
self.run_bzr('shelf switch default', retcode=0)
559
file('test_file', 'w').write(self.MODIFIED)
560
self.run_bzr('shelve --all test_file', retcode=0)
563
self.assertTrue(os.path.exists('.shelf/shelves/default/01'))
564
self.assertFalse(os.path.exists('.shelf/shelves/other/01'))
566
def test_shelf_binary(self):
567
self.tree = self.make_branch_and_tree('.')
568
self.build_tree_contents([('file', '\x00')])
569
self.tree.add('file')
570
self.run_bzr_error(['Changes involve binary files.'], 'shelve --all')
572
def test_shelf_bad_patch_arg(self):
573
self.tree = self.make_branch_and_tree('.')
575
# Check the bad arg handling
576
stdout, error = self.run_bzr('unshelve 01', retcode=3)
577
self.assertTrue("Patch '01' doesn't exist on shelf" in error)
579
stdout, error = self.run_bzr('unshelve foo', retcode=3)
580
self.assertTrue("Invalid patch name 'foo'" in error)
582
# Hex and is cracky, so it shouldn't work
583
stdout, error = self.run_bzr(['unshelve', '0x00'], retcode=3)
584
self.assertTrue("Invalid patch name '0x00'" in error)
586
def test_color_hunk_selector(self):
587
"""Make sure NoColor is raised iff terminal.has_ansi_colors is False"""
588
hs = ShelveHunkSelector([])
589
hs = UnshelveHunkSelector([])
591
from bzrlib.plugins.bzrtools import terminal
593
from bzrtools import terminal
594
old_has_ansi_colors = terminal.has_ansi_colors
595
terminal.has_ansi_colors = lambda: False
597
self.assertRaises(NoColor, ShelveHunkSelector, [], True)
598
self.assertRaises(NoColor, UnshelveHunkSelector, [], True)
599
terminal.has_ansi_colors = lambda: True
600
hs = ShelveHunkSelector([], color=True)
601
hs = UnshelveHunkSelector([], color=True)
603
terminal.has_ansi_colors = old_has_ansi_colors
605
def test_no_color(self):
606
"""Ensure --no-color switch can be passed"""
607
self.tree = self.make_branch_and_tree('.')
611
self.tree.add(subdir)
614
self.__create_and_add_test_file()
616
# Modify the test file
617
# write in binary mode because on win32 line-endings should be LF
618
f = file('test_file', 'wb')
619
f.write(self.MODIFIED)
621
stdout, error = self.run_bzr('shelve --all --no-color')
622
stdout, error = self.run_bzr('unshelve --all --no-color')
624
def test_shelf_help(self):
625
self.assertContainsRe(cmd_shelf().help(),
626
'list\n.*List the patches on the current shelf')
628
def test_show_empty_shelf(self):
629
self.tree = self.make_branch_and_tree('.')
630
self.run_bzr_error(('No patches on shelf.',), 'shelf show')
389
self.run_bzr('unshelve', '--all', retcode=0)
391
# Check the diff is right
392
self.assertEqual(self.capture('diff', retcode=1),
393
self.DIFF_HEADER + self.DIFF_1 + '\n')