38
38
from bzrlib.branch import Branch
39
39
from bzrlib.lockable_files import LockableFiles
40
from bzrlib.tests import TestCaseInTempDir, TestSkipped
41
from bzrlib.transport import get_transport
40
from bzrlib.tests import TestCaseWithTransport, TestSkipped
43
41
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
44
42
from bzrlib.transport import get_transport
43
from bzrlib.workingtree import WorkingTree
47
46
def chmod_r(base, file_mode, dir_mode):
84
83
'mode mismatch %o != %o' % (mode, mode_test))
87
class TestPermissions(TestCaseInTempDir):
86
class TestPermissions(TestCaseWithTransport):
89
88
def test_new_files(self):
90
89
if sys.platform == 'win32':
91
90
raise TestSkipped('chmod has no effect on win32')
93
b = Branch.initialize(u'.')
92
t = WorkingTree.create_standalone('.')
95
94
open('a', 'wb').write('foo\n')
159
158
# TODO: jam 20051215 Ultimately, this test should probably test that
160
159
# extra chmod calls aren't being made
162
transport = get_transport('.')
161
transport = get_transport(self.get_url())
163
162
transport.put('my-lock', StringIO(''))
164
163
lockable = LockableFiles(transport, 'my-lock')
165
164
self.assertNotEqual(None, lockable._dir_mode)
200
199
# also, these are BzrBranch format specific things..
202
201
mode = stat.S_IMODE(os.stat('a').st_mode)
203
b = Branch.initialize('a')
202
t = WorkingTree.create_standalone('.')
204
204
assertEqualMode(self, mode, b.control_files._dir_mode)
205
205
assertEqualMode(self, mode & ~07111, b.control_files._file_mode)
208
208
os.chmod('b', 02777)
209
b = Branch.initialize('b')
209
b = Branch.create('b')
210
210
assertEqualMode(self, 02777, b.control_files._dir_mode)
211
211
assertEqualMode(self, 00666, b.control_files._file_mode)
212
212
check_mode_r(self, 'b/.bzr', 00666, 02777)
215
215
os.chmod('c', 02750)
216
b = Branch.initialize('c')
216
b = Branch.create('c')
217
217
assertEqualMode(self, 02750, b.control_files._dir_mode)
218
218
assertEqualMode(self, 00640, b.control_files._file_mode)
219
219
check_mode_r(self, 'c/.bzr', 00640, 02750)
222
222
os.chmod('d', 0700)
223
b = Branch.initialize('d')
223
b = Branch.create('d')
224
224
assertEqualMode(self, 0700, b.control_files._dir_mode)
225
225
assertEqualMode(self, 0600, b.control_files._file_mode)
226
226
check_mode_r(self, 'd/.bzr', 00600, 0700)
242
242
_transport = SFTPTransport(self._sftp_url)
244
244
os.mkdir('local')
245
b_local = Branch.initialize(u'local')
246
t_local = b_local.working_tree()
245
t_local = WorkingTree.create_standalone('local')
246
b_local = t_local.branch
247
247
open('local/a', 'wb').write('foo\n')
249
249
t_local.commit('foo')