~benoit.pierre/bzrtools/shell_improvements

« back to all changes in this revision

Viewing changes to tests/shelf_tests.py

  • Committer: Benoît Pierre
  • Date: 2009-08-02 12:55:24 UTC
  • mfrom: (682.1.36 bzrtools)
  • Revision ID: benoit.pierre@gmail.com-20090802125524-1p2oot1y2l0y3o9w
Merge with upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    UnshelveHunkSelector,
8
8
    )
9
9
from bzrlib.plugins.bzrtools.errors import NoColor
10
 
from bzrlib.plugins.bzrtools.command_classes import cmd_shelf
 
10
from bzrlib.plugins.bzrtools.command_classes import cmd_shelf1
11
11
 
12
12
 
13
13
class ShelfTests(bzrlib.tests.TestCaseWithTransport):
188
188
        self.assertTrue('patch %s' % patch in shelf)
189
189
 
190
190
        # Check the shown output is right
191
 
        shown = self.run_bzr('shelf show %s' % patch, retcode=0)[0]
 
191
        shown = self.run_bzr('shelf1 show %s' % patch, retcode=0)[0]
192
192
        self.assertEqual(shown, shelf)
193
193
 
194
194
    def test_shelf_show_multi(self):
204
204
        self.assertTrue('patch 00' in shelf)
205
205
 
206
206
        # Check the shown output is right
207
 
        shown = self.run_bzr('shelf show 00', retcode=0)[0]
 
207
        shown = self.run_bzr('shelf1 show 00', retcode=0)[0]
208
208
        self.assertEqual(shown, shelf)
209
209
 
210
210
    def test_shelf_show_unspecified(self):
220
220
        self.assertTrue('patch 02' in shelf)
221
221
 
222
222
        # Check the shown output is right
223
 
        shown = self.run_bzr('shelf show', retcode=0)[0]
 
223
        shown = self.run_bzr('shelf1 show', retcode=0)[0]
224
224
        self.assertEqual(shown, shelf)
225
225
 
226
226
    def test_shelf_show_with_no_patch(self):
227
227
        self.tree = self.make_branch_and_tree('.')
228
 
        stderr = self.run_bzr('shelf show 00', retcode=None)[1]
 
228
        stderr = self.run_bzr('shelf1 show 00', retcode=None)[1]
229
229
        self.assertTrue("Patch '00' doesn't exist on shelf default!" in stderr)
230
230
 
231
231
    def test_shelf_unshelve_failure(self):
308
308
        self.assertTrue(os.path.exists('.shelf/shelves/default/01~'))
309
309
 
310
310
        # Check ls works
311
 
        lines = self.run_bzr('shelf ls', retcode=0)[0].split('\n')
 
311
        lines = self.run_bzr('shelf1 ls', retcode=0)[0].split('\n')
312
312
        for line in lines:
313
313
            self.assertFalse(line.startswith(' 01'))
314
314
 
342
342
        self._check_shelf('00', new_date=new_date)
343
343
 
344
344
        # Delete 00
345
 
        self.run_bzr('shelf delete 00', retcode=0)
 
345
        self.run_bzr('shelf1 delete 00', retcode=0)
346
346
 
347
347
        # We should now have 01 but not 00, but we should have 00~
348
348
        self.assertFalse(os.path.exists('.shelf/shelves/default/00'))
353
353
        self._check_shelf('00~', new_date=new_date)
354
354
 
355
355
        # Check ls works
356
 
        lines = self.run_bzr('shelf ls', retcode=0)[0].split('\n')
 
356
        lines = self.run_bzr('shelf1 ls', retcode=0)[0].split('\n')
357
357
        for line in lines:
358
358
            self.assertFalse(line.startswith(' 00'))
359
359
 
370
370
        self.run_bzr('shelve1 --all test_file', retcode=0)
371
371
 
372
372
        # Now delete 00, leaving 01, next shelve should go into 02
373
 
        self.run_bzr('shelf delete 0', retcode=0)
 
373
        self.run_bzr('shelf1 delete 0', retcode=0)
374
374
        self.assertFalse(os.path.exists('.shelf/shelves/default/00'))
375
375
        self.assertFalse(os.path.exists('.shelf/shelves/default/02'))
376
376
        file('test_file', 'w').write(self.MODIFIED)
400
400
        self.assertTrue(os.path.exists('.shelf/shelves/default/00'))
401
401
 
402
402
        # Upgrade, make sure it worked
403
 
        self.run_bzr('shelf upgrade', retcode=0)
 
403
        self.run_bzr('shelf1 upgrade', retcode=0)
404
404
        self.assertEqual(open('.shelf/shelves/default/01').read(),
405
405
                'First old shelf')
406
406
        self.assertEqual(open('.shelf/shelves/default/02').read(),
425
425
        self.__create_and_add_test_file()
426
426
 
427
427
        # Run a benign shelf command to setup .shelf for us
428
 
        self.run_bzr('shelf ls', retcode=0)
 
428
        self.run_bzr('shelf1 ls', retcode=0)
429
429
 
430
430
        old_tree = self.tree.basis_tree()
431
431
        old_tree.lock_read()
484
484
 
485
485
    def test_shelf_shelf_bogus_subcommand(self):
486
486
        self.tree = self.make_branch_and_tree('.')
487
 
        self.run_bzr('shelf foo', retcode=3) # <- retcode == 3
 
487
        self.run_bzr('shelf1 foo', retcode=3) # <- retcode == 3
488
488
 
489
489
    def test_shelf_OOO_unshelve(self):
490
490
        self.tree = self.make_branch_and_tree('.')
513
513
        self.assertEqual(file('test_file1').read(), self.MODIFIED)
514
514
 
515
515
        # Check ls works
516
 
        lines = self.run_bzr('shelf ls', retcode=0)[0].split('\n')
 
516
        lines = self.run_bzr('shelf1 ls', retcode=0)[0].split('\n')
517
517
        for line in lines:
518
518
            self.assertFalse(line.startswith(' 00'))
519
519
 
523
523
        self.assertTrue(os.path.exists('.shelf/shelves/default/04'))
524
524
 
525
525
        # Check ls works
526
 
        text = self.run_bzr('shelf ls', retcode=0)[0]
 
526
        text = self.run_bzr('shelf1 ls', retcode=0)[0]
527
527
        for line in text.split('\n'):
528
528
            self.assertFalse(line.startswith(' 00'))
529
529
 
545
545
        self.run_bzr('shelve1 --all test_file', retcode=0)
546
546
 
547
547
        # Switch to "other"
548
 
        self.run_bzr('shelf switch other', retcode=0)
 
548
        self.run_bzr('shelf1 switch other', retcode=0)
549
549
        file('test_file', 'w').write(self.MODIFIED)
550
550
        self.run_bzr('shelve1 --all test_file', retcode=0)
551
551
 
555
555
        self.assertTrue(os.path.exists('.shelf/shelves/other/00'))
556
556
 
557
557
        # Switch back
558
 
        self.run_bzr('shelf switch default', retcode=0)
 
558
        self.run_bzr('shelf1 switch default', retcode=0)
559
559
        file('test_file', 'w').write(self.MODIFIED)
560
560
        self.run_bzr('shelve1 --all test_file', retcode=0)
561
561
 
622
622
        stdout, error = self.run_bzr('unshelve1 --all --no-color')
623
623
 
624
624
    def test_shelf_help(self):
625
 
        self.assertContainsRe(cmd_shelf().help(),
 
625
        self.assertContainsRe(cmd_shelf1().help(),
626
626
                              'list\n.*List the patches on the current shelf')
627
627
 
628
628
    def test_show_empty_shelf(self):
629
629
        self.tree = self.make_branch_and_tree('.')
630
 
        self.run_bzr_error(('No patches on shelf.',), 'shelf show')
 
630
        self.run_bzr_error(('No patches on shelf.',), 'shelf1 show')