~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_permissions.py

Move working tree initialisation out from  Branch.initialize, deprecated Branch.initialize to Branch.create.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
from bzrlib.tests import TestCaseInTempDir, TestSkipped
39
39
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
40
40
from bzrlib.transport import get_transport
 
41
from bzrlib.workingtree import WorkingTree
41
42
 
42
43
 
43
44
def chmod_r(base, file_mode, dir_mode):
86
87
        if sys.platform == 'win32':
87
88
            raise TestSkipped('chmod has no effect on win32')
88
89
 
89
 
        b = Branch.initialize(u'.')
90
 
        t = b.working_tree()
 
90
        t = WorkingTree.create_standalone('.')
 
91
        b = t.branch
91
92
        open('a', 'wb').write('foo\n')
92
93
        t.add('a')
93
94
        t.commit('foo')
156
157
        #                    extra chmod calls aren't being made
157
158
        import bzrlib.branch
158
159
        try:
159
 
            b = Branch.initialize(u'.')
 
160
            t = WorkingTree.create_standalone('.')
 
161
            b = t.branch
160
162
            self.assertNotEqual(None, b._dir_mode)
161
163
            self.assertNotEqual(None, b._file_mode)
162
164
 
189
191
 
190
192
        os.mkdir('a')
191
193
        mode = stat.S_IMODE(os.stat('a').st_mode)
192
 
        b = Branch.initialize('a')
 
194
        t = WorkingTree.create_standalone('.')
 
195
        b = t.branch
193
196
        assertEqualMode(self, mode, b._dir_mode)
194
197
        assertEqualMode(self, mode & ~07111, b._file_mode)
195
198
 
196
199
        os.mkdir('b')
197
200
        os.chmod('b', 02777)
198
 
        b = Branch.initialize('b')
 
201
        b = Branch.create('b')
199
202
        assertEqualMode(self, 02777, b._dir_mode)
200
203
        assertEqualMode(self, 00666, b._file_mode)
201
204
        check_mode_r(self, 'b/.bzr', 00666, 02777)
202
205
 
203
206
        os.mkdir('c')
204
207
        os.chmod('c', 02750)
205
 
        b = Branch.initialize('c')
 
208
        b = Branch.create('c')
206
209
        assertEqualMode(self, 02750, b._dir_mode)
207
210
        assertEqualMode(self, 00640, b._file_mode)
208
211
        check_mode_r(self, 'c/.bzr', 00640, 02750)
209
212
 
210
213
        os.mkdir('d')
211
214
        os.chmod('d', 0700)
212
 
        b = Branch.initialize('d')
 
215
        b = Branch.create('d')
213
216
        assertEqualMode(self, 0700, b._dir_mode)
214
217
        assertEqualMode(self, 0600, b._file_mode)
215
218
        check_mode_r(self, 'd/.bzr', 00600, 0700)
231
234
        _transport = SFTPTransport(self._sftp_url)
232
235
 
233
236
        os.mkdir('local')
234
 
        b_local = Branch.initialize(u'local')
235
 
        t_local = b_local.working_tree()
 
237
        t_local = WorkingTree.create_standalone('local')
 
238
        b_local = t_local.branch
236
239
        open('local/a', 'wb').write('foo\n')
237
240
        t_local.add('a')
238
241
        t_local.commit('foo')
249
252
 
250
253
        os.mkdir('sftp')
251
254
        sftp_url = self.get_remote_url('sftp')
252
 
        b_sftp = Branch.initialize(sftp_url)
 
255
        b_sftp = Branch.create(sftp_url)
253
256
 
254
257
        b_sftp.pull(b_local)
255
258
        del b_sftp
317
320
            self.assertTransportMode(t, 'd', 0777)
318
321
        finally:
319
322
            os.umask(original_umask)
320
 
 
321