~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests.py

  • Committer: Michael Ellerman
  • Date: 2006-06-05 14:48:11 UTC
  • mto: (0.3.1 shelf-dev)
  • mto: This revision was merged to the branch mainline in revision 393.
  • Revision ID: michael@ellerman.id.au-20060605144811-d143d182c6fbe600
Support for unshelving in arbitrary order.

Normally the shelf acts as a LIFO, or more commonly a stack. However
there are times when this is inconvenient. Add support for unshelving
any of the patches on the shelf. This will obviously only work well if
the shelved patches don't depend on each other. Add tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
421
421
    def test_shelf_shelf_bogus_subcommand(self):
422
422
        self.tree = self.make_branch_and_tree('.')
423
423
        self.run_bzr('shelf', 'foo', retcode=3) # <- retcode == 3
 
424
 
 
425
    def test_shelf_OOO_unshelve(self):
 
426
        self.tree = self.make_branch_and_tree('.')
 
427
 
 
428
        for i in range(1, 5):
 
429
            self.__create_and_add_test_file(filename='test_file%d' % i)
 
430
 
 
431
        # Modify the test files
 
432
        for i in range(1, 5):
 
433
            file('test_file%d' % i, 'w').write(self.MODIFIED)
 
434
 
 
435
        # Shelve the changes
 
436
        for i in range(1, 5):
 
437
            self.run_bzr('shelve', '--all', 'test_file%d' % i, retcode=0)
 
438
 
 
439
        # Check shelving worked
 
440
        for i in range(1, 5):
 
441
            self.assertEqual(file('test_file%d' % i).read(), self.ORIGINAL)
 
442
 
 
443
        # We should now have 00-03
 
444
        for i in range(0, 4):
 
445
            self.assertTrue(os.path.exists('.shelf/shelves/default/0%d' % i))
 
446
 
 
447
        # Unshelve 00
 
448
        self.run_bzr('unshelve', '--all', '00', retcode=0)
 
449
        self.assertEqual(file('test_file1').read(), self.MODIFIED)
 
450
 
 
451
        # Check ls works
 
452
        list = self.capture('shelf ls', retcode=0).split('\n')
 
453
        for line in list:
 
454
            self.assertFalse(line.startswith(' 00'))
 
455
 
 
456
        # Check we can reshelve once we've unshelved out of order, should be 04
 
457
        self.assertFalse(os.path.exists('.shelf/shelves/default/04'))
 
458
        self.run_bzr('shelve', '--all')
 
459
        self.assertTrue(os.path.exists('.shelf/shelves/default/04'))
 
460
 
 
461
        # Check ls works
 
462
        text = self.capture('shelf ls', retcode=0)
 
463
        for line in text.split('\n'):
 
464
            self.assertFalse(line.startswith(' 00'))
 
465
 
 
466
        # We now have 01,02,03,04
 
467
        # Unshelve 02
 
468
        self.run_bzr('unshelve', '--all', '02', retcode=0)
 
469
        self.assertEqual(file('test_file3').read(), self.MODIFIED)
 
470
 
 
471
        # Unshelve the default, this is the reshelved 00, hence modifies file 1
 
472
        self.run_bzr('unshelve', '--all', retcode=0)
 
473
        self.assertEqual(file('test_file1').read(), self.MODIFIED)