~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revert.py

  • Committer: Aaron Bentley
  • Date: 2007-12-29 21:43:44 UTC
  • mto: This revision was merged to the branch mainline in revision 3162.
  • Revision ID: aaron.bentley@utoronto.ca-20071229214344-f24le3b1p943rywx
Fix locking issues in revert tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
        self.build_tree(['source/dir/', 'source/dir/contents'])
31
31
        source_tree.add(['dir', 'dir/contents'], ['dir-id', 'contents-id'])
32
32
        source_tree.commit('added dir')
 
33
        target_tree.lock_write()
 
34
        self.addCleanup(target_tree.unlock)
33
35
        merge.merge_inner(target_tree.branch, source_tree.basis_tree(), 
34
36
                          target_tree.basis_tree(), this_tree=target_tree)
35
37
        self.failUnlessExists('target/dir')
84
86
        tt = transform.TreeTransform(tree)
85
87
        tt.new_file('newfile', tt.root, 'helooo!', 'newfile-id', True)
86
88
        tt.apply()
87
 
        self.assertTrue(tree.is_executable('newfile-id'))
88
 
        tree.commit('added newfile')
 
89
        tree.lock_write()
 
90
        try:
 
91
            self.assertTrue(tree.is_executable('newfile-id'))
 
92
            tree.commit('added newfile')
 
93
        finally:
 
94
            tree.unlock()
89
95
        return tree
90
96
 
91
97
    def test_preserve_execute(self):
96
102
        tt.create_file('Woooorld!', newfile)
97
103
        tt.apply()
98
104
        tree = workingtree.WorkingTree.open('tree')
 
105
        tree.lock_write()
 
106
        self.addCleanup(tree.unlock)
99
107
        self.assertTrue(tree.is_executable('newfile-id'))
100
108
        transform.revert(tree, tree.basis_tree(), None, backups=True)
101
109
        self.assertEqual('helooo!', tree.get_file('newfile-id').read())
107
115
        newfile = tt.trans_id_tree_file_id('newfile-id')
108
116
        tt.set_executability(False, newfile)
109
117
        tt.apply()
 
118
        tree.lock_write()
 
119
        self.addCleanup(tree.unlock)
110
120
        transform.revert(tree, tree.basis_tree(), None)
111
121
        self.assertTrue(tree.is_executable('newfile-id'))
112
122