15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from bzrlib import merge, tests
18
from bzrlib import merge, tests, transform, workingtree
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')
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)
86
self.assertTrue(tree.is_executable('newfile-id'))
87
tree.commit('added newfile')
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)
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'))
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)
109
transform.revert(tree, tree.basis_tree(), [])
110
self.assertTrue(tree.is_executable('newfile-id'))