~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tests/test_prepare_shelf.py

  • Committer: Aaron Bentley
  • Date: 2008-10-05 21:45:16 UTC
  • mto: (0.15.1 unshelve)
  • mto: This revision was merged to the branch mainline in revision 3820.
  • Revision ID: aaron@aaronbentley.com-20081005214516-vj1wf3nfyfxazj3l
Add shelving of created files

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        creator.transform()
60
60
        self.assertEqual('foo/baz', tree.id2path('baz-id'))
61
61
 
 
62
    def assertShelvedFileEqual(self, expected_content, creator, file_id):
 
63
        s_trans_id = creator.shelf_transform.trans_id_file_id(file_id)
 
64
        shelf_file = creator.shelf_transform._limbo_name(s_trans_id)
 
65
        self.assertFileEqual(expected_content, shelf_file)
 
66
 
62
67
    def test_shelve_content_change(self):
63
68
        tree = self.make_branch_and_tree('.')
64
69
        tree.lock_write()
73
78
        creator.shelve_text('foo-id', 'a\nc\n')
74
79
        creator.transform()
75
80
        self.assertFileEqual('a\nc\n', 'foo')
76
 
        s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id')
77
 
        shelf_file = creator.shelf_transform._limbo_name(s_trans_id)
78
 
        self.assertFileEqual('b\na\n', shelf_file)
 
81
        self.assertShelvedFileEqual('b\na\n', creator, 'foo-id')
 
82
 
 
83
    def test_shelve_creation(self):
 
84
        tree = self.make_branch_and_tree('.')
 
85
        tree.lock_write()
 
86
        self.addCleanup(tree.unlock)
 
87
        tree.commit('Empty tree')
 
88
        self.build_tree_contents([('foo', 'a\n')])
 
89
        tree.add('foo', 'foo-id')
 
90
        creator = prepare_shelf.ShelfCreator(tree)
 
91
        self.addCleanup(creator.finalize)
 
92
        self.assertEqual([('add file', 'foo-id', 'file')], list(creator))
 
93
        creator.shelve_creation('foo-id', 'file')
 
94
        creator.transform()
 
95
        self.failIfExists('foo')
 
96
        self.assertShelvedFileEqual('a\n', creator, 'foo-id')