~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_permissions.py

  • Committer: Martin Pool
  • Date: 2006-02-01 12:24:35 UTC
  • mfrom: (1534.4.32 branch-formats)
  • mto: This revision was merged to the branch mainline in revision 1553.
  • Revision ID: mbp@sourcefrog.net-20060201122435-53f3efb1b5749fe1
[merge] branch-formats branch, and reconcile changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
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
42
 
 
 
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
45
44
 
46
45
 
47
46
def chmod_r(base, file_mode, dir_mode):
84
83
                     'mode mismatch %o != %o' % (mode, mode_test))
85
84
 
86
85
 
87
 
class TestPermissions(TestCaseInTempDir):
 
86
class TestPermissions(TestCaseWithTransport):
88
87
 
89
88
    def test_new_files(self):
90
89
        if sys.platform == 'win32':
91
90
            raise TestSkipped('chmod has no effect on win32')
92
91
 
93
 
        b = Branch.initialize(u'.')
94
 
        t = b.working_tree()
 
92
        t = WorkingTree.create_standalone('.')
 
93
        b = t.branch
95
94
        open('a', 'wb').write('foo\n')
96
95
        t.add('a')
97
96
        t.commit('foo')
159
158
        # TODO: jam 20051215 Ultimately, this test should probably test that
160
159
        #                    extra chmod calls aren't being made
161
160
        try:
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..
201
200
        os.mkdir('a')
202
201
        mode = stat.S_IMODE(os.stat('a').st_mode)
203
 
        b = Branch.initialize('a')
 
202
        t = WorkingTree.create_standalone('.')
 
203
        b = t.branch
204
204
        assertEqualMode(self, mode, b.control_files._dir_mode)
205
205
        assertEqualMode(self, mode & ~07111, b.control_files._file_mode)
206
206
 
207
207
        os.mkdir('b')
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)
213
213
 
214
214
        os.mkdir('c')
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)
220
220
 
221
221
        os.mkdir('d')
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)
243
243
 
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')
248
248
        t_local.add('a')
249
249
        t_local.commit('foo')
260
260
 
261
261
        os.mkdir('sftp')
262
262
        sftp_url = self.get_remote_url('sftp')
263
 
        b_sftp = Branch.initialize(sftp_url)
 
263
        b_sftp = Branch.create(sftp_url)
264
264
 
265
265
        b_sftp.pull(b_local)
266
266
        del b_sftp
328
328
            self.assertTransportMode(t, 'd', 0777)
329
329
        finally:
330
330
            os.umask(original_umask)
331
 
 
332