~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests.py

  • Committer: Michael Ellerman
  • Date: 2006-03-12 13:55:53 UTC
  • mto: (325.1.2 bzrtools) (0.3.1 shelf-dev)
  • mto: This revision was merged to the branch mainline in revision 334.
  • Revision ID: michael@ellerman.id.au-20060312135553-151b108c9d215d85
Add support for detecting and upgrading from old format shelves.

Show diffs side-by-side

added added

removed removed

Lines of Context:
300
300
        self.run_bzr('shelve', '--all', 'test_file', retcode=0)
301
301
        self.assertFalse(os.path.exists('.shelf/shelves/default/00'))
302
302
        self.assertTrue(os.path.exists('.shelf/shelves/default/02'))
 
303
 
 
304
    def test_shelf_upgrade(self):
 
305
        tree = self.make_branch_and_tree('.')
 
306
 
 
307
        self.__create_and_add_test_file(tree)
 
308
 
 
309
        # Modify then shelve, so we're not upgrading to 00, just for kicks
 
310
        file('test_file', 'w').write(self.MODIFIED)
 
311
        self.run_bzr('shelve', '--all', 'test_file', retcode=0)
 
312
 
 
313
        open('.bzr-shelf', 'w').write('First old shelf')
 
314
        open('.bzr-shelf-1', 'w').write('Second old shelf')
 
315
        open('.bzr-shelf-3', 'w').write('Fourth old shelf')
 
316
 
 
317
        # shelve and unshelve should bitch and do nothing
 
318
        file('test_file', 'w').write('blah blah blah')
 
319
        self.run_bzr('shelve', '--all', retcode=3)
 
320
        self.assertFalse(os.path.exists('.shelf/shelves/default/01'))
 
321
        self.assertEqual(file('test_file').read(), 'blah blah blah')
 
322
        self.run_bzr('unshelve', '--all', retcode=3)
 
323
        self.assertTrue(os.path.exists('.shelf/shelves/default/00'))
 
324
 
 
325
        # Upgrade, make sure it worked
 
326
        self.run_bzr('shelf', 'upgrade', retcode=0)
 
327
        self.assertEqual(open('.shelf/shelves/default/01').read(),
 
328
                'First old shelf')
 
329
        self.assertEqual(open('.shelf/shelves/default/02').read(),
 
330
                'Second old shelf')
 
331
        self.assertEqual(open('.shelf/shelves/default/03').read(),
 
332
                'Fourth old shelf')
 
333
 
 
334
        # Check the old shelves got backed up right
 
335
        self.assertTrue(os.path.exists('.bzr-shelf~'))
 
336
        self.assertTrue(os.path.exists('.bzr-shelf-1~'))
 
337
        self.assertTrue(os.path.exists('.bzr-shelf-3~'))
 
338
        self.assertFalse(os.path.exists('.bzr-shelf'))
 
339
        self.assertFalse(os.path.exists('.bzr-shelf-1'))
 
340
        self.assertFalse(os.path.exists('.bzr-shelf-3'))
 
341
 
 
342
        # Shelve should work now
 
343
        self.run_bzr('shelve', '--all', retcode=0)