~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/shelf_tests.py

  • Committer: Aaron Bentley
  • Date: 2006-06-23 18:19:25 UTC
  • Revision ID: abentley@panoramicfeedback.com-20060623181925-ae3ff20c166cab49
Clean up style

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
 
3
from bzrlib.diff import _patch_header_date
3
4
import bzrlib.tests
4
5
import os.path
5
6
 
6
7
class ShelfTests(bzrlib.tests.TestCaseWithTransport):
7
8
    ORIGINAL = '\n\nhello test world\n\n'
8
9
    MODIFIED = '\n\ngoodbye test world\n\n'
9
 
    DIFF_HEADER = "=== modified file 'a/test_file'\n"
10
 
    DIFF_1 = """--- a/test_file\t
11
 
+++ b/test_file\t
 
10
    DIFF_HEADER = "=== modified file '%(filename)s'\n"
 
11
    DIFF_1 = """--- %(filename)s\t%(old_date)s
 
12
+++ %(filename)s\t%(new_date)s
12
13
@@ -1,4 +1,4 @@
13
14
 
14
15
 
16
17
+goodbye test world
17
18
 
18
19
"""
19
 
    DIFF_2 = """--- a/test_file\t
20
 
+++ b/test_file\t
 
20
    DIFF_2 = """--- test_file\t%(old_date)s
 
21
+++ test_file\t%(new_date)s
21
22
@@ -1,4 +1,4 @@
22
23
 
23
24
 
25
26
+hello test world
26
27
 
27
28
"""
 
29
    def _check_diff(self, diff=DIFF_1, filename='test_file'):
 
30
        old_tree = self.tree.basis_tree()
 
31
        old_date = _patch_header_date(old_tree, 
 
32
                                      old_tree.inventory.path2id(filename),
 
33
                                      filename)
 
34
        new_date = _patch_header_date(self.tree, 
 
35
                                      self.tree.inventory.path2id(filename),
 
36
                                      filename)
 
37
        keys = { 'filename' : filename , 'old_date': old_date, 
 
38
                 'new_date': new_date}
 
39
        hdr  = self.DIFF_HEADER % keys
 
40
        diff = diff % keys
 
41
        self.assertEqual(self.capture('diff', retcode=1), hdr + diff + '\n')
 
42
 
 
43
    def _check_shelf(self, idx, diff=DIFF_1, filename='test_file',
 
44
                     new_date=None):
 
45
        old_tree = self.tree.basis_tree()
 
46
        old_date = _patch_header_date(old_tree, 
 
47
                                      old_tree.inventory.path2id(filename),
 
48
                                      filename)
 
49
        diff = diff % { 'filename' : filename, 'old_date': old_date,
 
50
                        'new_date': new_date}
 
51
        shelf = open(os.path.join(self.tree.basedir,
 
52
                '.shelf/shelves/default/' + idx)).read()
 
53
        shelf = shelf[shelf.index('\n') + 1:] # skip the message
 
54
        self.assertEqual(shelf, diff)
 
55
 
28
56
    def test_shelf(self):
29
57
        self.__test_loop(1)
30
58
 
32
60
        self.__test_loop(10)
33
61
 
34
62
    def __test_loop(self, count):
35
 
        tree = self.make_branch_and_tree('.')
36
 
        self.__create_and_add_test_file(tree)
 
63
        self.tree = self.make_branch_and_tree('.')
 
64
        self.__create_and_add_test_file()
37
65
 
38
66
        while count > 0:
39
67
            count -= 1
41
69
            # Modify the test file
42
70
            file('test_file', 'w').write(self.MODIFIED)
43
71
 
44
 
            # Check the diff is right
45
 
            self.assertEqual(self.capture('diff', retcode=1),
46
 
                self.DIFF_HEADER + self.DIFF_1 + '\n')
 
72
            self._check_diff()
 
73
            
 
74
            new_date = _patch_header_date(self.tree, 
 
75
                self.tree.inventory.path2id('test_file'), 'test_file')
47
76
 
48
77
            # Shelve the changes
49
78
            self.run_bzr('shelve', '--all', retcode=0)
54
83
            # Make sure the file is actually back the way it was
55
84
            self.assertEqual(file('test_file').read(), self.ORIGINAL)
56
85
 
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)
 
86
            self._check_shelf('00', new_date=new_date)
62
87
 
63
88
            # Unshelve
64
89
            self.run_bzr('unshelve', '--all', retcode=0)
65
90
 
66
 
            # Check the diff is right again
67
 
            self.assertEqual(self.capture('diff', retcode=1),
68
 
                self.DIFF_HEADER + self.DIFF_1 + '\n')
 
91
            self._check_diff()
69
92
 
70
93
            # Check the shelved patch was backed up
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)
 
94
            self._check_shelf('00~', new_date=new_date)
75
95
 
76
96
            # Make sure the file is back the way it should be
77
97
            self.assertEqual(file('test_file').read(), self.MODIFIED)
78
98
 
79
99
    def test_shelf_nothing_to_shelve(self):
80
100
        import os.path
81
 
        tree = self.make_branch_and_tree('.')
82
 
        self.__create_and_add_test_file(tree)
 
101
        self.tree = self.make_branch_and_tree('.')
 
102
        self.__create_and_add_test_file()
83
103
 
84
104
        # Shelve the changes
85
105
        self.run_bzr('shelve', '--all', retcode=3)
86
106
 
87
 
        if os.path.exists(os.path.join(tree.branch.base,
 
107
        if os.path.exists(os.path.join(self.tree.branch.base,
88
108
                '.shelf/shelves/default/00')):
89
109
            self.fail("Shelf exists, but it shouldn't")
90
110
 
91
 
    def __create_and_add_test_file(self, tree, filename='test_file'):
 
111
    def __create_and_add_test_file(self, filename='test_file'):
92
112
        f = open(filename, 'w')
93
113
        f.write(self.ORIGINAL)
94
114
        f.close()
95
 
        tree.add(tree.relpath(os.path.join(os.getcwd(), filename)))
96
 
        tree.commit(message='add %s' % filename)
 
115
        self.tree.add(self.tree.relpath(os.path.join(os.getcwd(), filename)))
 
116
        self.tree.commit(message='add %s' % filename)
97
117
 
98
118
    def test_shelf_with_revision(self):
99
 
        tree = self.make_branch_and_tree('.')
 
119
        self.tree = self.make_branch_and_tree('.')
100
120
 
101
 
        self.__create_and_add_test_file(tree)
 
121
        self.__create_and_add_test_file()
102
122
 
103
123
        # Modify the test file and commit it
104
124
        self.build_tree_contents([('test_file', self.MODIFIED)])
105
 
        tree.commit(message='update test_file')
 
125
        self.tree.commit(message='update test_file')
106
126
 
107
127
        # Shelve the changes
108
128
        self.run_bzr('shelve', '--all', '-r', '1', retcode=0)
109
129
 
110
 
        # Check the diff is right
111
 
        self.assertEqual(self.capture('diff', retcode=1),
112
 
            self.DIFF_HEADER + self.DIFF_2 + '\n')
 
130
        self._check_diff(self.DIFF_2)
113
131
 
114
132
        # Make sure the file is the way it should be
115
133
        self.assertEqual(file('test_file').read(), self.ORIGINAL)
121
139
        self.assertEqual(file('test_file').read(), self.MODIFIED)
122
140
 
123
141
    def test_shelf_with_two_revisions(self):
124
 
        tree = self.make_branch_and_tree('.')
 
142
        self.tree = self.make_branch_and_tree('.')
125
143
 
126
144
        cmd = 'shelve --all -r 1..2'
127
145
        (stdout, stderr) = self.run_bzr_captured(cmd.split(), retcode=None)
130
148
            'bzr: ERROR: shelve only accepts a single revision parameter.')
131
149
 
132
150
    def test_shelf_show_basic(self):
133
 
        tree = self.make_branch_and_tree('.')
134
 
        self.__create_and_add_test_file(tree)
135
 
        self.__test_show(tree, '00')
 
151
        self.tree = self.make_branch_and_tree('.')
 
152
        self.__create_and_add_test_file()
 
153
        self.__test_show(self.tree, '00')
136
154
 
137
155
    def __test_show(self, tree, patch):
138
156
        # Modify the test file
145
163
        self.assertEqual(self.capture('diff', retcode=0), '')
146
164
 
147
165
        # Check the shelf is right
148
 
        shelf = open(os.path.join(tree.branch.base,
 
166
        shelf = open(os.path.join(self.tree.basedir,
149
167
                    '.shelf/shelves/default', patch)).read()
150
168
        self.assertTrue('patch %s' % patch in shelf)
151
169
 
154
172
        self.assertEqual(shown, shelf)
155
173
 
156
174
    def test_shelf_show_multi(self):
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')
 
175
        self.tree = self.make_branch_and_tree('.')
 
176
        self.__create_and_add_test_file()
 
177
        self.__test_show(self.tree, '00')
 
178
        self.__test_show(self.tree, '01')
 
179
        self.__test_show(self.tree, '02')
162
180
 
163
181
        # Now check we can show a previously shelved patch
164
 
        shelf = open(os.path.join(tree.branch.base,
 
182
        shelf = open(os.path.join(self.tree.basedir,
165
183
                    '.shelf/shelves/default/00')).read()
166
184
        self.assertTrue('patch 00' in shelf)
167
185
 
169
187
        shown = self.capture('shelf show 00', retcode=0)
170
188
        self.assertEqual(shown, shelf)
171
189
 
 
190
    def test_shelf_show_unspecified(self):
 
191
        self.tree = self.make_branch_and_tree('.')
 
192
        self.__create_and_add_test_file()
 
193
        self.__test_show(self.tree, '00')
 
194
        self.__test_show(self.tree, '01')
 
195
        self.__test_show(self.tree, '02')
 
196
 
 
197
        # Check that not specifying at patch gets us the most recent
 
198
        shelf = open(os.path.join(self.tree.basedir,
 
199
                    '.shelf/shelves/default/02')).read()
 
200
        self.assertTrue('patch 02' in shelf)
 
201
 
 
202
        # Check the shown output is right
 
203
        shown = self.capture('shelf show', retcode=0)
 
204
        self.assertEqual(shown, shelf)
 
205
 
172
206
    def test_shelf_show_with_no_patch(self):
173
 
        tree = self.make_branch_and_tree('.')
 
207
        self.tree = self.make_branch_and_tree('.')
174
208
        stderr = self.run_bzr_captured(['shelf', 'show', '00'], retcode=None)[1]
175
209
        self.assertTrue("Patch '00' doesn't exist on shelf default!" in stderr)
176
210
 
177
211
    def test_shelf_unshelve_failure(self):
178
 
        tree = self.make_branch_and_tree('.')
 
212
        self.tree = self.make_branch_and_tree('.')
179
213
 
180
 
        self.__create_and_add_test_file(tree)
 
214
        self.__create_and_add_test_file()
181
215
 
182
216
        # Modify the test file
183
217
        file('test_file', 'w').write(self.MODIFIED)
186
220
        self.run_bzr('shelve', '--all', retcode=0)
187
221
 
188
222
        # Write an unapplyable patch into the shelf
189
 
        shelf = open(os.path.join(tree.branch.base,
 
223
        shelf = open(os.path.join(self.tree.basedir,
190
224
                    '.shelf/shelves/default/00'), 'w')
191
225
        shelf.write(self.DIFF_2)
192
226
        shelf.close()
195
229
        self.run_bzr('unshelve', '--all', retcode=3)
196
230
 
197
231
        # Make sure the patch is still there, eventhough it's broken
198
 
        shelf = open(os.path.join(tree.branch.base,
 
232
        shelf = open(os.path.join(self.tree.basedir,
199
233
                    '.shelf/shelves/default/00')).read()
200
234
        self.assertEqual(shelf, self.DIFF_2)
201
235
 
204
238
        self.assertEqual(diff, '')
205
239
 
206
240
    def test_shelf_unshelve_failure_two_hunks(self):
207
 
        tree = self.make_branch_and_tree('.')
 
241
        self.tree = self.make_branch_and_tree('.')
208
242
 
209
 
        self.__create_and_add_test_file(tree)
210
 
        self.__create_and_add_test_file(tree, filename='test_file2')
 
243
        self.__create_and_add_test_file()
 
244
        self.__create_and_add_test_file(filename='test_file2')
211
245
 
212
246
        # Modify the test files
213
247
        file('test_file', 'w').write(self.MODIFIED)
218
252
 
219
253
        # Put the changes to test_file back, the shelved patch won't apply now
220
254
        file('test_file', 'w').write(self.MODIFIED)
221
 
        tree.commit(message='screw up test_file')
 
255
        self.tree.commit(message='screw up test_file')
222
256
 
223
257
        # Unshelve, should fail
224
258
        self.run_bzr('unshelve', '--all', retcode=3)
233
267
        self.assertTrue(os.path.exists('.shelf/shelves/default/00'))
234
268
 
235
269
    def test_shelf_after_unshelve(self):
236
 
        tree = self.make_branch_and_tree('.')
 
270
        self.tree = self.make_branch_and_tree('.')
237
271
 
238
 
        self.__create_and_add_test_file(tree)
239
 
        self.__create_and_add_test_file(tree, filename='test_file2')
 
272
        self.__create_and_add_test_file()
 
273
        self.__create_and_add_test_file(filename='test_file2')
240
274
 
241
275
        # Modify the test files
242
276
        file('test_file', 'w').write(self.MODIFIED)
254
288
        self.assertTrue(os.path.exists('.shelf/shelves/default/01~'))
255
289
 
256
290
        # Check ls works
257
 
        list = self.capture('shelf ls', retcode=0).split('\n')
258
 
        for line in list:
 
291
        lines = self.capture('shelf ls', retcode=0).split('\n')
 
292
        for line in lines:
259
293
            self.assertFalse(line.startswith(' 01'))
260
294
 
261
295
        # Unshelve, if unshelve is confused by the backup it will fail
262
296
        self.run_bzr('unshelve', '--all', retcode=0)
263
297
 
264
298
    def test_shelf_delete(self):
265
 
        tree = self.make_branch_and_tree('.')
 
299
        self.tree = self.make_branch_and_tree('.')
266
300
 
267
 
        self.__create_and_add_test_file(tree)
268
 
        self.__create_and_add_test_file(tree, filename='test_file2')
 
301
        self.__create_and_add_test_file()
 
302
        self.__create_and_add_test_file(filename='test_file2')
269
303
 
270
304
        # Modify the test files
271
305
        file('test_file', 'w').write(self.MODIFIED)
272
306
        file('test_file2', 'w').write(self.MODIFIED)
 
307
        new_date = _patch_header_date(self.tree, 
 
308
            self.tree.inventory.path2id('test_file'), 'test_file')
273
309
 
274
310
        # Shelve the changes
275
311
        self.run_bzr('shelve', '--all', 'test_file', retcode=0)
276
312
        self.run_bzr('shelve', '--all', 'test_file2', retcode=0)
277
313
 
 
314
        self._check_shelf('00', new_date=new_date)
 
315
 
278
316
        # Delete 00
279
317
        self.run_bzr('shelf', 'delete', '00', retcode=0)
280
318
 
281
 
        # We should now have 01 but not 00
 
319
        # We should now have 01 but not 00, but we should have 00~
282
320
        self.assertFalse(os.path.exists('.shelf/shelves/default/00'))
 
321
        self.assertTrue(os.path.exists('.shelf/shelves/default/00~'))
283
322
        self.assertTrue(os.path.exists('.shelf/shelves/default/01'))
284
323
 
 
324
        # Check the backup is right
 
325
        self._check_shelf('00~', new_date=new_date)
 
326
 
285
327
        # Check ls works
286
 
        list = self.capture('shelf ls', retcode=0).split('\n')
287
 
        for line in list:
 
328
        lines = self.capture('shelf ls', retcode=0).split('\n')
 
329
        for line in lines:
288
330
            self.assertFalse(line.startswith(' 00'))
289
331
 
290
332
        # Unshelve should unshelve 01
292
334
        self.assertEqual(file('test_file2').read(), self.MODIFIED)
293
335
 
294
336
    def test_shelf_gaps(self):
295
 
        tree = self.make_branch_and_tree('.')
296
 
        self.__create_and_add_test_file(tree)
 
337
        self.tree = self.make_branch_and_tree('.')
 
338
        self.__create_and_add_test_file()
297
339
        file('test_file', 'w').write(self.MODIFIED)
298
340
        self.run_bzr('shelve', '--all', 'test_file', retcode=0)
299
341
        file('test_file', 'w').write(self.MODIFIED)
309
351
        self.assertTrue(os.path.exists('.shelf/shelves/default/02'))
310
352
 
311
353
    def test_shelf_upgrade(self):
312
 
        tree = self.make_branch_and_tree('.')
 
354
        self.tree = self.make_branch_and_tree('.')
313
355
 
314
 
        self.__create_and_add_test_file(tree)
 
356
        self.__create_and_add_test_file()
315
357
 
316
358
        # Modify then shelve, so we're not upgrading to 00, just for kicks
317
359
        file('test_file', 'w').write(self.MODIFIED)
349
391
        # Shelve should work now
350
392
        self.run_bzr('shelve', '--all', retcode=0)
351
393
 
352
 
    def test_shelf_p0_patch(self):
353
 
        tree = self.make_branch_and_tree('.')
 
394
    def test_shelf_p1_patch(self):
 
395
        self.tree = self.make_branch_and_tree('.')
354
396
 
355
 
        self.__create_and_add_test_file(tree)
 
397
        self.__create_and_add_test_file()
356
398
 
357
399
        # Run a benign shelf command to setup .shelf for us
358
400
        self.run_bzr('shelf', 'ls', retcode=0)
359
401
 
 
402
        old_tree = self.tree.basis_tree()
 
403
        old_date = _patch_header_date(old_tree, 
 
404
                                      old_tree.inventory.path2id('test_file'),
 
405
                                      'test_file')
 
406
        new_date = _patch_header_date(self.tree, 
 
407
                                      self.tree.inventory.path2id('test_file'),
 
408
                                      'test_file')
360
409
        # Fake a -p0 shelved patch
361
 
        diff = self.DIFF_1
362
 
        diff = diff.replace('a/', '')
363
 
        diff = diff.replace('b/', '')
 
410
        diff = self.DIFF_1 % { 'filename' : 'test_file', 'old_date': old_date,
 
411
                               'new_date' : new_date}
 
412
        diff = diff.replace('--- ', '--- a/')
 
413
        diff = diff.replace('+++ ', '+++ b/')
364
414
        open('.shelf/shelves/default/00', 'w').write(diff)
365
415
 
366
416
        # This should work
367
417
        self.run_bzr('unshelve', '--all', retcode=0)
368
418
 
369
 
        # Check the diff is right
370
 
        self.assertEqual(self.capture('diff', retcode=1),
371
 
            self.DIFF_HEADER + self.DIFF_1 + '\n')
 
419
        self._check_diff()
372
420
 
373
421
    def test_shelf_shelve_in_subdir(self):
374
 
        tree = self.make_branch_and_tree('.')
375
 
 
376
 
        self.__create_and_add_test_file(tree)
 
422
        self.tree = self.make_branch_and_tree('.')
 
423
 
 
424
        subdir = 'subdir'
 
425
        os.mkdir(subdir)
 
426
        self.tree.add(subdir)
 
427
        os.chdir(subdir)
 
428
 
 
429
        self.__create_and_add_test_file()
377
430
 
378
431
        # Modify the test file
379
432
        file('test_file', 'w').write(self.MODIFIED)
388
441
        # Unshelve, should succeed
389
442
        self.run_bzr('unshelve', '--all', retcode=0)
390
443
 
391
 
        # Check the diff is right
392
 
        self.assertEqual(self.capture('diff', retcode=1),
393
 
            self.DIFF_HEADER + self.DIFF_1 + '\n')
 
444
        self._check_diff(filename='subdir/test_file')
 
445
 
 
446
        # Make sure relative filenames work ok
 
447
        self.run_bzr('shelve', 'test_file', '--all', retcode=0)
 
448
 
 
449
    def test_shelf_shelf_bogus_subcommand(self):
 
450
        self.tree = self.make_branch_and_tree('.')
 
451
        self.run_bzr('shelf', 'foo', retcode=3) # <- retcode == 3
 
452
 
 
453
    def test_shelf_OOO_unshelve(self):
 
454
        self.tree = self.make_branch_and_tree('.')
 
455
 
 
456
        for i in range(1, 5):
 
457
            self.__create_and_add_test_file(filename='test_file%d' % i)
 
458
 
 
459
        # Modify the test files
 
460
        for i in range(1, 5):
 
461
            file('test_file%d' % i, 'w').write(self.MODIFIED)
 
462
 
 
463
        # Shelve the changes
 
464
        for i in range(1, 5):
 
465
            self.run_bzr('shelve', '--all', 'test_file%d' % i, retcode=0)
 
466
 
 
467
        # Check shelving worked
 
468
        for i in range(1, 5):
 
469
            self.assertEqual(file('test_file%d' % i).read(), self.ORIGINAL)
 
470
 
 
471
        # We should now have 00-03
 
472
        for i in range(0, 4):
 
473
            self.assertTrue(os.path.exists('.shelf/shelves/default/0%d' % i))
 
474
 
 
475
        # Unshelve 00
 
476
        self.run_bzr('unshelve', '--all', '00', retcode=0)
 
477
        self.assertEqual(file('test_file1').read(), self.MODIFIED)
 
478
 
 
479
        # Check ls works
 
480
        lines = self.capture('shelf ls', retcode=0).split('\n')
 
481
        for line in lines:
 
482
            self.assertFalse(line.startswith(' 00'))
 
483
 
 
484
        # Check we can reshelve once we've unshelved out of order, should be 04
 
485
        self.assertFalse(os.path.exists('.shelf/shelves/default/04'))
 
486
        self.run_bzr('shelve', '--all')
 
487
        self.assertTrue(os.path.exists('.shelf/shelves/default/04'))
 
488
 
 
489
        # Check ls works
 
490
        text = self.capture('shelf ls', retcode=0)
 
491
        for line in text.split('\n'):
 
492
            self.assertFalse(line.startswith(' 00'))
 
493
 
 
494
        # We now have 01,02,03,04
 
495
        # Unshelve 02
 
496
        self.run_bzr('unshelve', '--all', '02', retcode=0)
 
497
        self.assertEqual(file('test_file3').read(), self.MODIFIED)
 
498
 
 
499
        # Unshelve the default, this is the reshelved 00, hence modifies file 1
 
500
        self.run_bzr('unshelve', '--all', retcode=0)
 
501
        self.assertEqual(file('test_file1').read(), self.MODIFIED)
 
502
 
 
503
    def test_shelf_switch_basic(self):
 
504
        self.tree = self.make_branch_and_tree('.')
 
505
        self.__create_and_add_test_file()
 
506
 
 
507
        # This should go to "default"
 
508
        file('test_file', 'w').write(self.MODIFIED)
 
509
        self.run_bzr('shelve', '--all', 'test_file', retcode=0)
 
510
 
 
511
        # Switch to "other"
 
512
        self.run_bzr('shelf', 'switch', 'other', retcode=0)
 
513
        file('test_file', 'w').write(self.MODIFIED)
 
514
        self.run_bzr('shelve', '--all', 'test_file', retcode=0)
 
515
 
 
516
        # Check it worked
 
517
        self.assertTrue(os.path.exists('.shelf/shelves/default/00'))
 
518
        self.assertFalse(os.path.exists('.shelf/shelves/default/01'))
 
519
        self.assertTrue(os.path.exists('.shelf/shelves/other/00'))
 
520
 
 
521
        # Switch back
 
522
        self.run_bzr('shelf', 'switch', 'default', retcode=0)
 
523
        file('test_file', 'w').write(self.MODIFIED)
 
524
        self.run_bzr('shelve', '--all', 'test_file', retcode=0)
 
525
 
 
526
        # Check that worked
 
527
        self.assertTrue(os.path.exists('.shelf/shelves/default/01'))
 
528
        self.assertFalse(os.path.exists('.shelf/shelves/other/01'))
 
529
 
 
530
    def test_shelf_bad_patch_arg(self):
 
531
        self.tree = self.make_branch_and_tree('.')
 
532
 
 
533
        # Check the bad arg handling
 
534
        stdout, error = self.run_bzr_captured(['unshelve', '01'], retcode=3)
 
535
        self.assertTrue("Patch '01' doesn't exist on shelf" in error)
 
536
 
 
537
        stdout, error = self.run_bzr_captured(['unshelve', 'foo'], retcode=3)
 
538
        self.assertTrue("Invalid patch name 'foo'" in error)
 
539
 
 
540
        # Hex and is cracky, so it shouldn't work
 
541
        stdout, error = self.run_bzr_captured(['unshelve', '0x00'], retcode=3)
 
542
        self.assertTrue("Invalid patch name '0x00'" in error)