24
24
In the future, when we have Repository/Branch/Checkout information, the
25
25
permissions should be inherited individually, rather than all be the same.
27
TODO: jam 20051215 There are no tests for ftp yet, because we have no ftp server
28
TODO: jam 20051215 Currently the default behavior for 'bzr branch' is just
29
defined by the local umask. This isn't terrible, is it
30
the truly desired behavior?
28
# TODO: jam 20051215 There are no tests for ftp yet, because we have no ftp server
29
# TODO: jam 20051215 Currently the default behavior for 'bzr branch' is just
30
# defined by the local umask. This isn't terrible, is it
31
# the truly desired behavior?
36
from StringIO import StringIO
37
38
from bzrlib.branch import Branch
39
from bzrlib.lockable_files import LockableFiles
38
40
from bzrlib.tests import TestCaseInTempDir, TestSkipped
41
from bzrlib.transport import get_transport
39
43
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
40
44
from bzrlib.transport import get_transport
154
158
def test_disable_set_mode(self):
155
159
# TODO: jam 20051215 Ultimately, this test should probably test that
156
160
# extra chmod calls aren't being made
159
b = Branch.initialize(u'.')
160
self.assertNotEqual(None, b._dir_mode)
161
self.assertNotEqual(None, b._file_mode)
163
bzrlib.branch.BzrBranch._set_dir_mode = False
164
b = Branch.open(u'.')
165
self.assertEqual(None, b._dir_mode)
166
self.assertNotEqual(None, b._file_mode)
168
bzrlib.branch.BzrBranch._set_file_mode = False
169
b = Branch.open(u'.')
170
self.assertEqual(None, b._dir_mode)
171
self.assertEqual(None, b._file_mode)
173
bzrlib.branch.BzrBranch._set_dir_mode = True
174
b = Branch.open(u'.')
175
self.assertNotEqual(None, b._dir_mode)
176
self.assertEqual(None, b._file_mode)
178
bzrlib.branch.BzrBranch._set_file_mode = True
179
b = Branch.open(u'.')
180
self.assertNotEqual(None, b._dir_mode)
181
self.assertNotEqual(None, b._file_mode)
162
transport = get_transport('.')
163
transport.put('my-lock', StringIO(''))
164
lockable = LockableFiles(transport, 'my-lock')
165
self.assertNotEqual(None, lockable._dir_mode)
166
self.assertNotEqual(None, lockable._file_mode)
168
LockableFiles._set_dir_mode = False
169
transport = get_transport('.')
170
lockable = LockableFiles(transport, 'my-lock')
171
self.assertEqual(None, lockable._dir_mode)
172
self.assertNotEqual(None, lockable._file_mode)
174
LockableFiles._set_file_mode = False
175
transport = get_transport('.')
176
lockable = LockableFiles(transport, 'my-lock')
177
self.assertEqual(None, lockable._dir_mode)
178
self.assertEqual(None, lockable._file_mode)
180
LockableFiles._set_dir_mode = True
181
transport = get_transport('.')
182
lockable = LockableFiles(transport, 'my-lock')
183
self.assertNotEqual(None, lockable._dir_mode)
184
self.assertEqual(None, lockable._file_mode)
186
LockableFiles._set_file_mode = True
187
transport = get_transport('.')
188
lockable = LockableFiles(transport, 'my-lock')
189
self.assertNotEqual(None, lockable._dir_mode)
190
self.assertNotEqual(None, lockable._file_mode)
183
bzrlib.branch.BzrBranch._set_dir_mode = True
184
bzrlib.branch.BzrBranch._set_file_mode = True
192
LockableFiles._set_dir_mode = True
193
LockableFiles._set_file_mode = True
186
195
def test_new_branch(self):
187
196
if sys.platform == 'win32':
188
197
raise TestSkipped('chmod has no effect on win32')
198
#FIXME RBC 20060105 should test branch and repository
200
# also, these are BzrBranch format specific things..
191
202
mode = stat.S_IMODE(os.stat('a').st_mode)
192
203
b = Branch.initialize('a')
193
assertEqualMode(self, mode, b._dir_mode)
194
assertEqualMode(self, mode & ~07111, b._file_mode)
204
assertEqualMode(self, mode, b.control_files._dir_mode)
205
assertEqualMode(self, mode & ~07111, b.control_files._file_mode)
197
208
os.chmod('b', 02777)
198
209
b = Branch.initialize('b')
199
assertEqualMode(self, 02777, b._dir_mode)
200
assertEqualMode(self, 00666, b._file_mode)
210
assertEqualMode(self, 02777, b.control_files._dir_mode)
211
assertEqualMode(self, 00666, b.control_files._file_mode)
201
212
check_mode_r(self, 'b/.bzr', 00666, 02777)
204
215
os.chmod('c', 02750)
205
216
b = Branch.initialize('c')
206
assertEqualMode(self, 02750, b._dir_mode)
207
assertEqualMode(self, 00640, b._file_mode)
217
assertEqualMode(self, 02750, b.control_files._dir_mode)
218
assertEqualMode(self, 00640, b.control_files._file_mode)
208
219
check_mode_r(self, 'c/.bzr', 00640, 02750)
211
222
os.chmod('d', 0700)
212
223
b = Branch.initialize('d')
213
assertEqualMode(self, 0700, b._dir_mode)
214
assertEqualMode(self, 0600, b._file_mode)
224
assertEqualMode(self, 0700, b.control_files._dir_mode)
225
assertEqualMode(self, 0600, b.control_files._file_mode)
215
226
check_mode_r(self, 'd/.bzr', 00600, 0700)