~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revert.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-11-04 18:51:39 UTC
  • mfrom: (2961.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20071104185139-kaio3sneodg2kp71
Authentication ring implementation (read-only)

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)
35
33
        merge.merge_inner(target_tree.branch, source_tree.basis_tree(), 
36
34
                          target_tree.basis_tree(), this_tree=target_tree)
37
35
        self.failUnlessExists('target/dir')
86
84
        tt = transform.TreeTransform(tree)
87
85
        tt.new_file('newfile', tt.root, 'helooo!', 'newfile-id', True)
88
86
        tt.apply()
89
 
        tree.lock_write()
90
 
        try:
91
 
            self.assertTrue(tree.is_executable('newfile-id'))
92
 
            tree.commit('added newfile')
93
 
        finally:
94
 
            tree.unlock()
 
87
        self.assertTrue(tree.is_executable('newfile-id'))
 
88
        tree.commit('added newfile')
95
89
        return tree
96
90
 
97
91
    def test_preserve_execute(self):
102
96
        tt.create_file('Woooorld!', newfile)
103
97
        tt.apply()
104
98
        tree = workingtree.WorkingTree.open('tree')
105
 
        tree.lock_write()
106
 
        self.addCleanup(tree.unlock)
107
99
        self.assertTrue(tree.is_executable('newfile-id'))
108
100
        transform.revert(tree, tree.basis_tree(), None, backups=True)
109
101
        self.assertEqual('helooo!', tree.get_file('newfile-id').read())
115
107
        newfile = tt.trans_id_tree_file_id('newfile-id')
116
108
        tt.set_executability(False, newfile)
117
109
        tt.apply()
118
 
        tree.lock_write()
119
 
        self.addCleanup(tree.unlock)
120
110
        transform.revert(tree, tree.basis_tree(), None)
121
111
        self.assertTrue(tree.is_executable('newfile-id'))
122
112
 
142
132
            ' as of bzr 0.91.  Please use None (the default) instead.'],
143
133
            tree.revert, [])
144
134
        self.assertIs(None, tree.path2id('file'))
145
 
 
146
 
    def test_revert_file_in_deleted_dir(self):
147
 
        tree = self.make_branch_and_tree('.')
148
 
        self.build_tree(['dir/', 'dir/file1', 'dir/file2'])
149
 
        tree.add(['dir', 'dir/file1', 'dir/file2'],
150
 
                 ['dir-id', 'file1-id', 'file2-id'])
151
 
        tree.commit("Added files")
152
 
        os.unlink('dir/file1')
153
 
        os.unlink('dir/file2')
154
 
        os.rmdir('dir')
155
 
        tree.remove(['dir/', 'dir/file1', 'dir/file2'])
156
 
        tree.revert(['dir/file1'])
157
 
        self.failUnlessExists('dir/file1')
158
 
        self.failIfExists('dir/file2')
159
 
        self.assertEqual('dir-id', tree.path2id('dir'))