99
99
b = Branch.open('.')
100
100
t = b.working_tree()
101
assertEqualMode(self, 0755, b._dir_mode)
102
assertEqualMode(self, 0644, b._file_mode)
101
assertEqualMode(self, 0755, b.control_files._dir_mode)
102
assertEqualMode(self, 0644, b.control_files._file_mode)
104
104
# Modifying a file shouldn't break the permissions
105
105
open('a', 'wb').write('foo2\n')
119
119
check_mode_r(self, '.bzr', 0664, 0775)
120
120
b = Branch.open('.')
121
121
t = b.working_tree()
122
assertEqualMode(self, 0775, b._dir_mode)
123
assertEqualMode(self, 0664, b._file_mode)
122
assertEqualMode(self, 0775, b.control_files._dir_mode)
123
assertEqualMode(self, 0664, b.control_files._file_mode)
125
125
open('a', 'wb').write('foo3\n')
138
138
check_mode_r(self, '.bzr', 0664, 02775)
139
139
b = Branch.open('.')
140
140
t = b.working_tree()
141
assertEqualMode(self, 02775, b._dir_mode)
142
assertEqualMode(self, 0664, b._file_mode)
141
assertEqualMode(self, 02775, b.control_files._dir_mode)
142
assertEqualMode(self, 0664, b.control_files._file_mode)
144
144
open('a', 'wb').write('foo4\n')
153
153
def test_disable_set_mode(self):
154
154
# TODO: jam 20051215 Ultimately, this test should probably test that
155
155
# extra chmod calls aren't being made
156
import bzrlib.lockable_files
158
158
b = Branch.initialize(u'.')
159
self.assertNotEqual(None, b._dir_mode)
160
self.assertNotEqual(None, b._file_mode)
162
bzrlib.branch.BzrBranch._set_dir_mode = False
163
b = Branch.open(u'.')
164
self.assertEqual(None, b._dir_mode)
165
self.assertNotEqual(None, b._file_mode)
167
bzrlib.branch.BzrBranch._set_file_mode = False
168
b = Branch.open(u'.')
169
self.assertEqual(None, b._dir_mode)
170
self.assertEqual(None, b._file_mode)
172
bzrlib.branch.BzrBranch._set_dir_mode = True
173
b = Branch.open(u'.')
174
self.assertNotEqual(None, b._dir_mode)
175
self.assertEqual(None, b._file_mode)
177
bzrlib.branch.BzrBranch._set_file_mode = True
178
b = Branch.open(u'.')
179
self.assertNotEqual(None, b._dir_mode)
180
self.assertNotEqual(None, b._file_mode)
159
self.assertNotEqual(None, b.control_files._dir_mode)
160
self.assertNotEqual(None, b.control_files._file_mode)
162
bzrlib.lockable_files.LockableFiles._set_dir_mode = False
163
b = Branch.open(u'.')
164
self.assertEqual(None, b.control_files._dir_mode)
165
self.assertNotEqual(None, b.control_files._file_mode)
167
bzrlib.lockable_files.LockableFiles._set_file_mode = False
168
b = Branch.open(u'.')
169
self.assertEqual(None, b.control_files._dir_mode)
170
self.assertEqual(None, b.control_files._file_mode)
172
bzrlib.lockable_files.LockableFiles._set_dir_mode = True
173
b = Branch.open(u'.')
174
self.assertNotEqual(None, b.control_files._dir_mode)
175
self.assertEqual(None, b.control_files._file_mode)
177
bzrlib.lockable_files.LockableFiles._set_file_mode = True
178
b = Branch.open(u'.')
179
self.assertNotEqual(None, b.control_files._dir_mode)
180
self.assertNotEqual(None, b.control_files._file_mode)
182
bzrlib.branch.BzrBranch._set_dir_mode = True
183
bzrlib.branch.BzrBranch._set_file_mode = True
182
bzrlib.lockable_files.LockableFiles._set_dir_mode = True
183
bzrlib.lockable_files.LockableFiles._set_file_mode = True
185
185
def test_new_branch(self):
186
186
if sys.platform == 'win32':
190
190
mode = stat.S_IMODE(os.stat('a').st_mode)
191
191
b = Branch.initialize('a')
192
assertEqualMode(self, mode, b._dir_mode)
193
assertEqualMode(self, mode & ~07111, b._file_mode)
192
assertEqualMode(self, mode, b.control_files._dir_mode)
193
assertEqualMode(self, mode & ~07111, b.control_files._file_mode)
196
196
os.chmod('b', 02777)
197
197
b = Branch.initialize('b')
198
assertEqualMode(self, 02777, b._dir_mode)
199
assertEqualMode(self, 00666, b._file_mode)
198
assertEqualMode(self, 02777, b.control_files._dir_mode)
199
assertEqualMode(self, 00666, b.control_files._file_mode)
200
200
check_mode_r(self, 'b/.bzr', 00666, 02777)
203
203
os.chmod('c', 02750)
204
204
b = Branch.initialize('c')
205
assertEqualMode(self, 02750, b._dir_mode)
206
assertEqualMode(self, 00640, b._file_mode)
205
assertEqualMode(self, 02750, b.control_files._dir_mode)
206
assertEqualMode(self, 00640, b.control_files._file_mode)
207
207
check_mode_r(self, 'c/.bzr', 00640, 02750)
210
210
os.chmod('d', 0700)
211
211
b = Branch.initialize('d')
212
assertEqualMode(self, 0700, b._dir_mode)
213
assertEqualMode(self, 0600, b._file_mode)
212
assertEqualMode(self, 0700, b.control_files._dir_mode)
213
assertEqualMode(self, 0600, b.control_files._file_mode)
214
214
check_mode_r(self, 'd/.bzr', 00600, 0700)
245
245
b_local = Branch.open(u'local')
246
246
t_local = b_local.working_tree()
247
assertEqualMode(self, 0755, b_local._dir_mode)
248
assertEqualMode(self, 0644, b_local._file_mode)
247
assertEqualMode(self, 0755, b_local.control_files._dir_mode)
248
assertEqualMode(self, 0644, b_local.control_files._file_mode)
251
251
# Why does self._sftp_url end with a slash????
258
258
check_mode_r(self, 'sftp/.bzr', 0644, 0755)
260
260
b_sftp = Branch.open(sftp_url)
261
assertEqualMode(self, 0755, b_sftp._dir_mode)
262
assertEqualMode(self, 0644, b_sftp._file_mode)
261
assertEqualMode(self, 0755, b_sftp.control_files._dir_mode)
262
assertEqualMode(self, 0644, b_sftp.control_files._file_mode)
264
264
open('local/a', 'wb').write('foo2\n')
265
265
t_local.commit('foo2')
279
279
check_mode_r(self, 'sftp/.bzr', 0664, 0775)
281
281
b_sftp = Branch.open(sftp_url)
282
assertEqualMode(self, 0775, b_sftp._dir_mode)
283
assertEqualMode(self, 0664, b_sftp._file_mode)
282
assertEqualMode(self, 0775, b_sftp.control_files._dir_mode)
283
assertEqualMode(self, 0664, b_sftp.control_files._file_mode)
285
285
open('local/a', 'wb').write('foo3\n')
286
286
t_local.commit('foo3')