~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_permissions.py

MergeĀ fromĀ jam-storage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
 
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)
103
103
 
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)
124
124
 
125
125
        open('a', 'wb').write('foo3\n')
126
126
        t.commit('foo3')
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)
143
143
 
144
144
        open('a', 'wb').write('foo4\n')
145
145
        t.commit('foo4')
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.branch
 
156
        import bzrlib.lockable_files
157
157
        try:
158
158
            b = Branch.initialize(u'.')
159
 
            self.assertNotEqual(None, b._dir_mode)
160
 
            self.assertNotEqual(None, b._file_mode)
161
 
 
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)
166
 
 
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)
171
 
 
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)
176
 
 
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)
 
161
 
 
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)
 
166
 
 
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)
 
171
 
 
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)
 
176
 
 
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)
181
181
        finally:
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
184
184
 
185
185
    def test_new_branch(self):
186
186
        if sys.platform == 'win32':
189
189
        os.mkdir('a')
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)
194
194
 
195
195
        os.mkdir('b')
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)
201
201
 
202
202
        os.mkdir('c')
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)
208
208
 
209
209
        os.mkdir('d')
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)
215
215
 
216
216
 
244
244
 
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)
249
249
 
250
250
        os.mkdir('sftp')
251
251
        # Why does self._sftp_url end with a slash????
258
258
        check_mode_r(self, 'sftp/.bzr', 0644, 0755)
259
259
 
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)
263
263
 
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)
280
280
 
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)
284
284
 
285
285
        open('local/a', 'wb').write('foo3\n')
286
286
        t_local.commit('foo3')