1
# Copyright (C) 2006 by Canonical Ltd
1
# Copyright (C) 2006 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
42
45
def check_exist(self, tree):
43
46
"""Just check that both files have the right executable bits set"""
45
for cn, ie in tree.inventory.iter_entries():
46
if isinstance(ie, InventoryFile):
47
measured.append((cn, ie.executable))
48
self.assertEqual([('a', True), ('b', False)], measured)
49
48
self.failUnless(tree.is_executable(self.a_id),
50
49
"'a' lost the execute bit")
51
50
self.failIf(tree.is_executable(self.b_id),
52
51
"'b' gained an execute bit")
54
54
def check_empty(self, tree, ignore_inv=False):
55
55
"""Check that the files are truly missing
57
57
the inventory still shows them, so don't assert that
58
58
the inventory is empty, just that the tree doesn't have them
62
63
[('', tree.inventory.root)],
65
66
self.failIf(tree.has_filename('a'))
66
67
self.failIf(tree.has_id(self.b_id))
67
68
self.failIf(tree.has_filename('b'))
69
71
def commit_and_branch(self):
70
72
"""Commit the current tree, and create a second tree"""
71
73
self.wt.commit('adding a,b', rev_id='r1')
73
74
# Now make sure that 'bzr branch' also preserves the
75
76
# TODO: Maybe this should be a blackbox test
127
128
rev_tree = self.wt.branch.repository.revision_tree('r1')
128
129
# Now revert back to the previous commit
129
self.wt.revert([], rev_tree, backups=False)
130
self.wt.revert(old_tree=rev_tree, backups=False)
131
132
self.check_exist(self.wt)
157
158
# so that the second branch can pull the changes
158
159
# and make sure that the executable bit has been copied
159
160
rev_tree = self.wt.branch.repository.revision_tree('r1')
160
self.wt.revert([], rev_tree, backups=False)
161
self.wt.revert(old_tree=rev_tree, backups=False)
161
162
self.wt.commit('resurrected', rev_id='r3')
163
164
self.check_exist(self.wt)
175
176
self.wt.commit('adding a,b', rev_id='r1')
176
177
rev_tree = self.wt.branch.repository.revision_tree('r1')
177
self.wt.revert([], rev_tree, backups=False)
178
self.wt.revert(old_tree=rev_tree, backups=False)
178
179
self.check_exist(self.wt)
181
def test_commit_with_exec_from_basis(self):
182
self.wt._is_executable_from_path_and_stat = \
183
self.wt._is_executable_from_path_and_stat_from_basis
184
rev_id1 = self.wt.commit('one')
185
rev_tree1 = self.wt.branch.repository.revision_tree(rev_id1)
186
a_executable = rev_tree1.inventory[self.a_id].executable
187
b_executable = rev_tree1.inventory[self.b_id].executable
188
self.assertIsNot(None, a_executable)
189
self.assertTrue(a_executable)
190
self.assertIsNot(None, b_executable)
191
self.assertFalse(b_executable)
193
def test_use_exec_from_basis(self):
194
if osutils.supports_executable():
195
self.assertEqual(self.wt._is_executable_from_path_and_stat_from_stat,
196
self.wt._is_executable_from_path_and_stat)
198
self.assertEqual(self.wt._is_executable_from_path_and_stat_from_basis,
199
self.wt._is_executable_from_path_and_stat)