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'))
304
def test_shelf_upgrade(self):
305
tree = self.make_branch_and_tree('.')
307
self.__create_and_add_test_file(tree)
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)
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')
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'))
325
# Upgrade, make sure it worked
326
self.run_bzr('shelf', 'upgrade', retcode=0)
327
self.assertEqual(open('.shelf/shelves/default/01').read(),
329
self.assertEqual(open('.shelf/shelves/default/02').read(),
331
self.assertEqual(open('.shelf/shelves/default/03').read(),
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'))
342
# Shelve should work now
343
self.run_bzr('shelve', '--all', retcode=0)