~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_permissions.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:56:05 UTC
  • mfrom: (6615.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201195605-o7rl92wf6uyum3fk
(vila) Open trunk again as 2.8b1 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
import os
30
30
import sys
31
31
import stat
32
 
from StringIO import StringIO
33
32
 
34
33
from bzrlib import tests
35
 
from bzrlib.branch import Branch
36
 
from bzrlib.bzrdir import BzrDir
37
 
from bzrlib.lockable_files import LockableFiles
 
34
from bzrlib.branch import BzrBranch
 
35
from bzrlib.controldir import ControlDir
38
36
from bzrlib.remote import RemoteBranchFormat
39
 
from bzrlib.tests.test_permissions import chmod_r, check_mode_r
40
 
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
41
 
from bzrlib.workingtree import WorkingTree
 
37
from bzrlib.tests.test_permissions import check_mode_r
42
38
 
43
39
 
44
40
class _NullPermsStat(object):
63
59
                                          ' permission logic')
64
60
        if sys.platform == 'win32':
65
61
            raise tests.TestNotApplicable('chmod has no effect on win32')
66
 
        # also, these are BzrBranch format specific things..
67
62
        os.mkdir('a')
68
63
        mode = stat.S_IMODE(os.stat('a').st_mode)
69
64
        t = self.make_branch_and_tree('.')
 
65
        # also, these are BzrBranch format specific things..
 
66
        if not isinstance(t.branch, BzrBranch):
 
67
            raise tests.TestNotApplicable(
 
68
                "Only applicable to bzr branches")
70
69
        b = t.branch
71
70
        self.assertEqualMode(mode, b.bzrdir._get_dir_mode())
72
71
        self.assertEqualMode(mode & ~07111, b.bzrdir._get_file_mode())
90
89
                                          ' permission logic')
91
90
        if sys.platform == 'win32':
92
91
            raise tests.TestNotApplicable('chmod has no effect on win32')
93
 
        elif sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
94
 
            # OS X (and FreeBSD) create temp dirs with the 'wheel' group, which
95
 
            # users are not likely to be in, and this prevents us from setting
96
 
            # the sgid bit
 
92
        elif sys.platform == 'darwin' or 'freebsd' in sys.platform:
 
93
            # FreeBSD-based platforms create temp dirs with the 'wheel' group,
 
94
            # which users are not likely to be in, and this prevents us
 
95
            # from setting the sgid bit
97
96
            os.chown(self.test_dir, os.getuid(), os.getgid())
98
 
        # also, these are BzrBranch format specific things..
99
97
        t = self.make_branch_and_tree('.')
100
98
        b = t.branch
 
99
        # also, these are BzrBranch format specific things..
 
100
        if not isinstance(b, BzrBranch):
 
101
            raise tests.TestNotApplicable(
 
102
                "Only applicable to bzr branches")
101
103
        os.mkdir('b')
102
104
        os.chmod('b', 02777)
103
105
        b = self.make_branch('b')
124
126
            raise tests.TestNotApplicable('Remote branches have no'
125
127
                                          ' permission logic')
126
128
        self.make_branch_and_tree('.')
127
 
        bzrdir = BzrDir.open('.')
 
129
        bzrdir = ControlDir.open('.')
128
130
        # Monkey patch the transport
129
131
        _orig_stat = bzrdir.transport.stat
130
132
        def null_perms_stat(*args, **kwargs):