~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: 2006-12-07 17:20:51 UTC
  • mfrom: (1551.9.10 Aaron's mergeable stuff)
  • Revision ID: pqm@pqm.ubuntu.com-20061207172051-43fe52677c8dfb85
Fix bugs in execute bit handling by revert

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
 
from bzrlib import merge, tests
 
18
from bzrlib import merge, tests, transform, workingtree
19
19
 
20
20
 
21
21
class TestRevert(tests.TestCaseWithTransport):
77
77
        self.build_tree_contents([('merge_target/new_file', 'new_contents')])
78
78
        merge_target.revert([])
79
79
        self.failUnlessExists('merge_target/new_file')
 
80
 
 
81
    def tree_with_executable(self):
 
82
        tree = self.make_branch_and_tree('tree')
 
83
        tt = transform.TreeTransform(tree)
 
84
        tt.new_file('newfile', tt.root, 'helooo!', 'newfile-id', True)
 
85
        tt.apply()
 
86
        self.assertTrue(tree.is_executable('newfile-id'))
 
87
        tree.commit('added newfile')
 
88
        return tree
 
89
 
 
90
    def test_preserve_execute(self):
 
91
        tree = self.tree_with_executable()
 
92
        tt = transform.TreeTransform(tree)
 
93
        newfile = tt.trans_id_tree_file_id('newfile-id')
 
94
        tt.delete_contents(newfile)
 
95
        tt.create_file('Woooorld!', newfile)
 
96
        tt.apply()
 
97
        tree = workingtree.WorkingTree.open('tree')
 
98
        self.assertTrue(tree.is_executable('newfile-id'))
 
99
        transform.revert(tree, tree.basis_tree(), [], backups=True)
 
100
        self.assertEqual('helooo!', tree.get_file('newfile-id').read())
 
101
        self.assertTrue(tree.is_executable('newfile-id'))
 
102
 
 
103
    def test_revert_executable(self):
 
104
        tree = self.tree_with_executable()
 
105
        tt = transform.TreeTransform(tree)
 
106
        newfile = tt.trans_id_tree_file_id('newfile-id')
 
107
        tt.set_executability(False, newfile)
 
108
        tt.apply()
 
109
        transform.revert(tree, tree.basis_tree(), [])
 
110
        self.assertTrue(tree.is_executable('newfile-id'))