~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf.py

  • Committer: Jonathan Riddell
  • Date: 2011-05-16 11:27:37 UTC
  • mto: This revision was merged to the branch mainline in revision 5869.
  • Revision ID: jriddell@canonical.com-20110516112737-gep642p24rtzp3jt
userĀ guideĀ licence

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    transform,
26
26
    workingtree,
27
27
    )
28
 
from bzrlib.tests import (
29
 
    features,
30
 
    )
31
28
 
32
29
 
33
30
EMPTY_SHELF = ("Bazaar pack format 1 (introduced in 0.18)\n"
217
214
 
218
215
    def _test_shelve_symlink_creation(self, link_name, link_target,
219
216
                                      shelve_change=False):
220
 
        self.requireFeature(features.SymlinkFeature)
 
217
        self.requireFeature(tests.SymlinkFeature)
221
218
        tree = self.make_branch_and_tree('.')
222
219
        tree.lock_write()
223
220
        self.addCleanup(tree.unlock)
244
241
        self._test_shelve_symlink_creation('foo', 'bar')
245
242
 
246
243
    def test_shelve_unicode_symlink_creation(self):
247
 
        self.requireFeature(features.UnicodeFilenameFeature)
 
244
        self.requireFeature(tests.UnicodeFilenameFeature)
248
245
        self._test_shelve_symlink_creation(u'fo\N{Euro Sign}o',
249
246
                                           u'b\N{Euro Sign}ar')
250
247
 
254
251
    def _test_shelve_symlink_target_change(self, link_name,
255
252
                                           old_target, new_target,
256
253
                                           shelve_change=False):
257
 
        self.requireFeature(features.SymlinkFeature)
 
254
        self.requireFeature(tests.SymlinkFeature)
258
255
        tree = self.make_branch_and_tree('.')
259
256
        tree.lock_write()
260
257
        self.addCleanup(tree.unlock)
285
282
        self._test_shelve_symlink_target_change('foo', 'bar', 'baz')
286
283
 
287
284
    def test_shelve_unicode_symlink_target_change(self):
288
 
        self.requireFeature(features.UnicodeFilenameFeature)
 
285
        self.requireFeature(tests.UnicodeFilenameFeature)
289
286
        self._test_shelve_symlink_target_change(
290
287
            u'fo\N{Euro Sign}o', u'b\N{Euro Sign}ar', u'b\N{Euro Sign}az')
291
288
 
333
330
        return creator, tree
334
331
 
335
332
    def check_shelve_deletion(self, tree):
336
 
        self.assertTrue(tree.has_id('foo-id'))
337
 
        self.assertTrue(tree.has_id('bar-id'))
 
333
        self.assertTrue('foo-id' in tree)
 
334
        self.assertTrue('bar-id' in tree)
338
335
        self.assertFileEqual('baz', 'tree/foo/bar')
339
336
 
340
337
    def test_shelve_deletion(self):
571
568
        list(creator.iter_shelvable())
572
569
        creator.shelve_deletion('foo-id')
573
570
        creator.shelve_deletion('bar-id')
574
 
        with open('shelf', 'w+b') as shelf_file:
575
 
            creator.write_shelf(shelf_file)
576
 
            creator.transform()
577
 
            creator.finalize()
 
571
        shelf_file = open('shelf', 'w+b')
 
572
        self.addCleanup(shelf_file.close)
 
573
        creator.write_shelf(shelf_file)
 
574
        creator.transform()
 
575
        creator.finalize()
578
576
        # validate the test setup
579
 
        self.assertTrue(tree.has_id('foo-id'))
580
 
        self.assertTrue(tree.has_id('bar-id'))
 
577
        self.assertTrue('foo-id' in tree)
 
578
        self.assertTrue('bar-id' in tree)
581
579
        self.assertFileEqual('baz', 'tree/foo/bar')
582
 
        with open('shelf', 'r+b') as shelf_file:
583
 
            unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file)
584
 
            self.addCleanup(unshelver.finalize)
585
 
            unshelver.make_merger().do_merge()
586
 
        self.assertFalse(tree.has_id('foo-id'))
587
 
        self.assertFalse(tree.has_id('bar-id'))
 
580
        shelf_file.seek(0)
 
581
        unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file)
 
582
        self.addCleanup(unshelver.finalize)
 
583
        unshelver.make_merger().do_merge()
 
584
        self.assertFalse('foo-id' in tree)
 
585
        self.assertFalse('bar-id' in tree)
588
586
 
589
587
    def test_unshelve_base(self):
590
588
        tree = self.make_branch_and_tree('tree')