~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf.py

(gz) Change minimum required testtools version for selftest to 0.9.5 for
 unicode fixes (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2011 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
191
191
        s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id')
192
192
        self.assertEqual('foo-id',
193
193
                         creator.shelf_transform.final_file_id(s_trans_id))
194
 
        self.assertPathDoesNotExist('foo')
195
 
        self.assertPathDoesNotExist('bar')
 
194
        self.failIfExists('foo')
 
195
        self.failIfExists('bar')
196
196
        self.assertShelvedFileEqual('a\n', creator, 'foo-id')
197
197
        s_bar_trans_id = creator.shelf_transform.trans_id_file_id('bar-id')
198
198
        self.assertEqual('directory',
231
231
            creator.shelve_creation('foo-id')
232
232
        creator.transform()
233
233
        s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id')
234
 
        self.assertPathDoesNotExist(link_name)
 
234
        self.failIfExists(link_name)
235
235
        limbo_name = creator.shelf_transform._limbo_name(s_trans_id)
236
236
        self.assertEqual(link_target, osutils.readlink(limbo_name))
237
237
        ptree = creator.shelf_transform.get_preview_tree()
310
310
        s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id')
311
311
        self.assertEqual('foo-id',
312
312
                         creator.shelf_transform.final_file_id(s_trans_id))
313
 
        self.assertPathDoesNotExist('foo')
 
313
        self.failIfExists('foo')
314
314
 
315
315
    def prepare_shelve_deletion(self):
316
316
        tree = self.make_branch_and_tree('tree')
362
362
                         sorted(list(creator.iter_shelvable())))
363
363
        creator.shelve_deletion('foo-id')
364
364
        creator.transform()
365
 
        self.assertPathExists('tree/foo')
 
365
        self.failUnlessExists('tree/foo')
366
366
 
367
367
    def prepare_shelve_change_kind(self):
368
368
        tree = self.make_branch_and_tree('tree')
421
421
                         sorted(list(creator.iter_shelvable())))
422
422
        creator.shelve_deletion('foo-id')
423
423
        creator.transform()
424
 
        self.assertPathExists('tree/foo')
 
424
        self.failUnlessExists('tree/foo')
425
425
 
426
426
    def test_shelve_serialization(self):
427
427
        tree = self.make_branch_and_tree('.')
623
623
                              shelf_file)
624
624
        self.assertEqual('Shelf corrupt.', str(e))
625
625
 
626
 
    def test_unshelve_subdir_in_now_removed_dir(self):
627
 
        tree = self.make_branch_and_tree('.')
628
 
        self.addCleanup(tree.lock_write().unlock)
629
 
        self.build_tree(['dir/', 'dir/subdir/', 'dir/subdir/foo'])
630
 
        tree.add(['dir'], ['dir-id'])
631
 
        tree.commit('versioned dir')
632
 
        tree.add(['dir/subdir', 'dir/subdir/foo'], ['subdir-id', 'foo-id'])
633
 
        creator = shelf.ShelfCreator(tree, tree.basis_tree())
634
 
        self.addCleanup(creator.finalize)
635
 
        for change in creator.iter_shelvable():
636
 
            creator.shelve_change(change)
637
 
        shelf_manager = tree.get_shelf_manager()
638
 
        shelf_id = shelf_manager.shelve_changes(creator)
639
 
        self.assertPathDoesNotExist('dir/subdir')
640
 
        tree.remove(['dir'])
641
 
        unshelver = shelf_manager.get_unshelver(shelf_id)
642
 
        self.addCleanup(unshelver.finalize)
643
 
        unshelver.make_merger().do_merge()
644
 
        self.assertPathExists('dir/subdir/foo')
645
 
        self.assertEqual('dir-id', tree.path2id('dir'))
646
 
        self.assertEqual('subdir-id', tree.path2id('dir/subdir'))
647
 
        self.assertEqual('foo-id', tree.path2id('dir/subdir/foo'))
648
 
 
649
626
 
650
627
class TestShelfManager(tests.TestCaseWithTransport):
651
628
 
746
723
        creator.shelve_creation('foo-id')
747
724
        shelf_manager = tree.get_shelf_manager()
748
725
        shelf_id = shelf_manager.shelve_changes(creator)
749
 
        self.assertPathDoesNotExist('tree/foo')
 
726
        self.failIfExists('tree/foo')
750
727
        unshelver = shelf_manager.get_unshelver(shelf_id)
751
728
        self.addCleanup(unshelver.finalize)
752
729
        unshelver.make_merger().do_merge()