~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_permissions.py

  • Committer: Samuel Bronson
  • Date: 2012-08-30 20:36:18 UTC
  • mto: (6015.57.3 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: naesten@gmail.com-20120830203618-y2dzw91nqpvpgxvx
Update INSTALL for switch to Python 2.6 and up.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
import os
34
34
import sys
 
35
import urllib
35
36
 
36
 
from bzrlib import urlutils
 
37
from bzrlib import transport
37
38
from bzrlib.branch import Branch
38
 
from bzrlib.controldir import ControlDir
 
39
from bzrlib.bzrdir import BzrDir
39
40
from bzrlib.tests import TestCaseWithTransport, TestSkipped
40
41
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
41
42
from bzrlib.workingtree import WorkingTree
67
68
        test.assertTransportMode(t, base, dir_mode)
68
69
    for root, dirs, files in os.walk(base):
69
70
        for d in dirs:
70
 
            p = '/'.join([urlutils.quote(x) for x in root.split('/\\') + [d]])
 
71
            p = '/'.join([urllib.quote(x) for x in root.split('/\\') + [d]])
71
72
            test.assertTransportMode(t, p, dir_mode)
72
73
        for f in files:
73
74
            p = os.path.join(root, f)
74
 
            p = '/'.join([urlutils.quote(x) for x in root.split('/\\') + [f]])
 
75
            p = '/'.join([urllib.quote(x) for x in root.split('/\\') + [f]])
75
76
            test.assertTransportMode(t, p, file_mode)
76
77
 
77
78
 
83
84
 
84
85
        t = self.make_branch_and_tree('.')
85
86
        b = t.branch
86
 
        with open('a', 'wb') as f: f.write('foo\n')
 
87
        open('a', 'wb').write('foo\n')
87
88
        # ensure check_mode_r works with capital-letter file-ids like TREE_ROOT
88
89
        t.add('a', 'CAPS-ID')
89
90
        t.commit('foo')
104
105
        self.assertEqualMode(0644, b.bzrdir._get_file_mode())
105
106
 
106
107
        # Modifying a file shouldn't break the permissions
107
 
        with open('a', 'wb') as f: f.write('foo2\n')
 
108
        open('a', 'wb').write('foo2\n')
108
109
        t.commit('foo2')
109
110
        # The mode should be maintained after commit
110
111
        check_mode_r(self, '.bzr', 0644, 0755)
111
112
 
112
113
        # Adding a new file should maintain the permissions
113
 
        with open('b', 'wb') as f: f.write('new b\n')
 
114
        open('b', 'wb').write('new b\n')
114
115
        t.add('b')
115
116
        t.commit('new b')
116
117
        check_mode_r(self, '.bzr', 0644, 0755)
125
126
        self.assertEqualMode(0775, b.bzrdir._get_dir_mode())
126
127
        self.assertEqualMode(0664, b.bzrdir._get_file_mode())
127
128
 
128
 
        with open('a', 'wb') as f: f.write('foo3\n')
 
129
        open('a', 'wb').write('foo3\n')
129
130
        t.commit('foo3')
130
131
        check_mode_r(self, '.bzr', 0664, 0775)
131
132
 
132
 
        with open('c', 'wb') as f: f.write('new c\n')
 
133
        open('c', 'wb').write('new c\n')
133
134
        t.add('c')
134
135
        t.commit('new c')
135
136
        check_mode_r(self, '.bzr', 0664, 0775)
157
158
        self.assertEqualMode(02775, b.bzrdir._get_dir_mode())
158
159
        self.assertEqualMode(0664, b.bzrdir._get_file_mode())
159
160
 
160
 
        with open('a', 'wb') as f: f.write('foo4\n')
 
161
        open('a', 'wb').write('foo4\n')
161
162
        t.commit('foo4')
162
163
        check_mode_r(self, '.bzr', 0664, 02775)
163
164
 
164
 
        with open('d', 'wb') as f: f.write('new d\n')
 
165
        open('d', 'wb').write('new d\n')
165
166
        t.add('d')
166
167
        t.commit('new d')
167
168
        check_mode_r(self, '.bzr', 0664, 02775)
182
183
        os.mkdir('local')
183
184
        t_local = self.make_branch_and_tree('local')
184
185
        b_local = t_local.branch
185
 
        with open('local/a', 'wb') as f: f.write('foo\n')
 
186
        open('local/a', 'wb').write('foo\n')
186
187
        t_local.add('a')
187
188
        t_local.commit('foo')
188
189
 
199
200
 
200
201
        os.mkdir('sftp')
201
202
        sftp_url = self.get_url('sftp')
202
 
        b_sftp = ControlDir.create_branch_and_repo(sftp_url)
 
203
        b_sftp = BzrDir.create_branch_and_repo(sftp_url)
203
204
 
204
205
        b_sftp.pull(b_local)
205
206
        del b_sftp
212
213
        self.assertEqualMode(0755, b_sftp.bzrdir._get_dir_mode())
213
214
        self.assertEqualMode(0644, b_sftp.bzrdir._get_file_mode())
214
215
 
215
 
        with open('local/a', 'wb') as f: f.write('foo2\n')
 
216
        open('local/a', 'wb').write('foo2\n')
216
217
        t_local.commit('foo2')
217
218
        b_sftp.pull(b_local)
218
219
        # The mode should be maintained after commit
219
220
        check_mode_r(self, 'sftp/.bzr', 0644, 0755)
220
221
 
221
 
        with open('local/b', 'wb') as f: f.write('new b\n')
 
222
        open('local/b', 'wb').write('new b\n')
222
223
        t_local.add('b')
223
224
        t_local.commit('new b')
224
225
        b_sftp.pull(b_local)
235
236
        self.assertEqualMode(0775, b_sftp.bzrdir._get_dir_mode())
236
237
        self.assertEqualMode(0664, b_sftp.bzrdir._get_file_mode())
237
238
 
238
 
        with open('local/a', 'wb') as f: f.write('foo3\n')
 
239
        open('local/a', 'wb').write('foo3\n')
239
240
        t_local.commit('foo3')
240
241
        b_sftp.pull(b_local)
241
242
        check_mode_r(self, 'sftp/.bzr', 0664, 0775)
242
243
 
243
 
        with open('local/c', 'wb') as f: f.write('new c\n')
 
244
        open('local/c', 'wb').write('new c\n')
244
245
        t_local.add('c')
245
246
        t_local.commit('new c')
246
247
        b_sftp.pull(b_local)