/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
import sys
31
31
import stat
32
32
 
33
 
from bzrlib import tests
34
 
from bzrlib.branch import BzrBranch
35
 
from bzrlib.controldir import ControlDir
36
 
from bzrlib.remote import RemoteBranchFormat
37
 
from bzrlib.tests.test_permissions import check_mode_r
 
33
from breezy import tests
 
34
from breezy.branch import BzrBranch
 
35
from breezy.controldir import ControlDir
 
36
from breezy.remote import RemoteBranchFormat
 
37
from breezy.tests.test_permissions import check_mode_r
38
38
 
39
39
 
40
40
class _NullPermsStat(object):
43
43
    def __init__(self, orig_stat):
44
44
        self._orig_stat = orig_stat
45
45
        # We strip all permission bits from st_mode
46
 
        self.st_mode = orig_stat.st_mode & ~07777
 
46
        self.st_mode = orig_stat.st_mode & ~0o7777
47
47
 
48
48
    def __getattr__(self, name):
49
49
        return getattr(self._orig_stat, name)
68
68
                "Only applicable to bzr branches")
69
69
        b = t.branch
70
70
        self.assertEqualMode(mode, b.bzrdir._get_dir_mode())
71
 
        self.assertEqualMode(mode & ~07111, b.bzrdir._get_file_mode())
 
71
        self.assertEqualMode(mode & ~0o7111, b.bzrdir._get_file_mode())
72
72
        self.assertEqualMode(mode, b.control_files._dir_mode)
73
 
        self.assertEqualMode(mode & ~07111, b.control_files._file_mode)
 
73
        self.assertEqualMode(mode & ~0o7111, b.control_files._file_mode)
74
74
 
75
75
        os.mkdir('d')
76
 
        os.chmod('d', 0700)
 
76
        os.chmod('d', 0o700)
77
77
        b = self.make_branch('d')
78
 
        self.assertEqualMode(0700, b.bzrdir._get_dir_mode())
79
 
        self.assertEqualMode(0600, b.bzrdir._get_file_mode())
80
 
        self.assertEqualMode(0700, b.control_files._dir_mode)
81
 
        self.assertEqualMode(0600, b.control_files._file_mode)
82
 
        check_mode_r(self, 'd/.bzr', 00600, 00700)
 
78
        self.assertEqualMode(0o700, b.bzrdir._get_dir_mode())
 
79
        self.assertEqualMode(0o600, b.bzrdir._get_file_mode())
 
80
        self.assertEqualMode(0o700, b.control_files._dir_mode)
 
81
        self.assertEqualMode(0o600, b.control_files._file_mode)
 
82
        check_mode_r(self, 'd/.bzr', 0o0600, 0o0700)
83
83
 
84
84
    def test_new_branch_group_sticky_bit(self):
85
85
        if isinstance(self.branch_format, RemoteBranchFormat):
101
101
            raise tests.TestNotApplicable(
102
102
                "Only applicable to bzr branches")
103
103
        os.mkdir('b')
104
 
        os.chmod('b', 02777)
 
104
        os.chmod('b', 0o2777)
105
105
        b = self.make_branch('b')
106
 
        self.assertEqualMode(02777, b.bzrdir._get_dir_mode())
107
 
        self.assertEqualMode(00666, b.bzrdir._get_file_mode())
108
 
        self.assertEqualMode(02777, b.control_files._dir_mode)
109
 
        self.assertEqualMode(00666, b.control_files._file_mode)
110
 
        check_mode_r(self, 'b/.bzr', 00666, 02777)
 
106
        self.assertEqualMode(0o2777, b.bzrdir._get_dir_mode())
 
107
        self.assertEqualMode(0o0666, b.bzrdir._get_file_mode())
 
108
        self.assertEqualMode(0o2777, b.control_files._dir_mode)
 
109
        self.assertEqualMode(0o0666, b.control_files._file_mode)
 
110
        check_mode_r(self, 'b/.bzr', 0o0666, 0o2777)
111
111
 
112
112
        os.mkdir('c')
113
 
        os.chmod('c', 02750)
 
113
        os.chmod('c', 0o2750)
114
114
        b = self.make_branch('c')
115
 
        self.assertEqualMode(02750, b.bzrdir._get_dir_mode())
116
 
        self.assertEqualMode(00640, b.bzrdir._get_file_mode())
117
 
        self.assertEqualMode(02750, b.control_files._dir_mode)
118
 
        self.assertEqualMode(00640, b.control_files._file_mode)
119
 
        check_mode_r(self, 'c/.bzr', 00640, 02750)
 
115
        self.assertEqualMode(0o2750, b.bzrdir._get_dir_mode())
 
116
        self.assertEqualMode(0o0640, b.bzrdir._get_file_mode())
 
117
        self.assertEqualMode(0o2750, b.control_files._dir_mode)
 
118
        self.assertEqualMode(0o0640, b.control_files._file_mode)
 
119
        check_mode_r(self, 'c/.bzr', 0o0640, 0o2750)
120
120
 
121
121
    def test_mode_0(self):
122
122
        """Test when a transport returns null permissions for .bzr"""