53
53
os.chmod(p, file_mode)
56
def check_mode_r(test, base, file_mode, dir_mode):
57
"""Check that all permissions match"""
56
def check_mode_r(test, base, file_mode, dir_mode, include_base=True):
57
"""Check that all permissions match
59
:param test: The TestCase being run
60
:param base: The path to the root directory to check
61
:param file_mode: The mode for all files
62
:param dir_mode: The mode for all directories
63
:param include_base: If false, only check the subdirectories
65
assert os.path.isdir(base)
67
check_mode(test, base, dir_mode)
58
68
for root, dirs, files in os.walk(base):
60
70
p = os.path.join(root, d)
138
148
t.commit('new d')
139
149
check_mode_r(self, '.bzr', 0664, 02775)
151
def test_disable_set_mode(self):
152
# TODO: jam 20051215 Ultimately, this test should probably test that
153
# extra chmod calls aren't being made
156
b = Branch.initialize(u'.')
157
self.assertNotEqual(None, b._dir_mode)
158
self.assertNotEqual(None, b._file_mode)
160
bzrlib.branch.BzrBranch._set_dir_mode = False
161
b = Branch.open(u'.')
162
self.assertEqual(None, b._dir_mode)
163
self.assertNotEqual(None, b._file_mode)
165
bzrlib.branch.BzrBranch._set_file_mode = False
166
b = Branch.open(u'.')
167
self.assertEqual(None, b._dir_mode)
168
self.assertEqual(None, b._file_mode)
170
bzrlib.branch.BzrBranch._set_dir_mode = True
171
b = Branch.open(u'.')
172
self.assertNotEqual(None, b._dir_mode)
173
self.assertEqual(None, b._file_mode)
175
bzrlib.branch.BzrBranch._set_file_mode = True
176
b = Branch.open(u'.')
177
self.assertNotEqual(None, b._dir_mode)
178
self.assertNotEqual(None, b._file_mode)
180
bzrlib.branch.BzrBranch._set_dir_mode = True
181
bzrlib.branch.BzrBranch._set_file_mode = True
183
def test_new_branch(self):
184
if sys.platform == 'win32':
185
raise TestSkipped('chmod has no effect on win32')
188
mode = stat.S_IMODE(os.stat('a').st_mode)
189
b = Branch.initialize('a')
190
assertEqualMode(self, mode, b._dir_mode)
191
assertEqualMode(self, mode & ~07111, b._file_mode)
195
b = Branch.initialize('b')
196
assertEqualMode(self, 02777, b._dir_mode)
197
assertEqualMode(self, 00666, b._file_mode)
198
check_mode_r(self, 'b/.bzr', 00666, 02777)
202
b = Branch.initialize('c')
203
assertEqualMode(self, 02750, b._dir_mode)
204
assertEqualMode(self, 00640, b._file_mode)
205
check_mode_r(self, 'c/.bzr', 00640, 02750)
209
b = Branch.initialize('d')
210
assertEqualMode(self, 0700, b._dir_mode)
211
assertEqualMode(self, 0600, b._file_mode)
212
check_mode_r(self, 'd/.bzr', 00600, 0700)
143
216
except ImportError: