/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_permissions.py

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
 
84
84
        t = self.make_branch_and_tree('.')
85
85
        b = t.branch
86
 
        with open('a', 'wb') as f:
87
 
            f.write(b'foo\n')
 
86
        with open('a', 'wb') as f: f.write(b'foo\n')
88
87
        # ensure check_mode_r works with capital-letter file-ids like TREE_ROOT
89
 
        t.add('a', b'CAPS-ID')
 
88
        t.add('a', 'CAPS-ID')
90
89
        t.commit('foo')
91
90
 
92
91
        chmod_r('.bzr', 0o644, 0o755)
105
104
        self.assertEqualMode(0o644, b.controldir._get_file_mode())
106
105
 
107
106
        # Modifying a file shouldn't break the permissions
108
 
        with open('a', 'wb') as f:
109
 
            f.write(b'foo2\n')
 
107
        with open('a', 'wb') as f: f.write(b'foo2\n')
110
108
        t.commit('foo2')
111
109
        # The mode should be maintained after commit
112
110
        check_mode_r(self, '.bzr', 0o644, 0o755)
113
111
 
114
112
        # Adding a new file should maintain the permissions
115
 
        with open('b', 'wb') as f:
116
 
            f.write(b'new b\n')
 
113
        with open('b', 'wb') as f: f.write(b'new b\n')
117
114
        t.add('b')
118
115
        t.commit('new b')
119
116
        check_mode_r(self, '.bzr', 0o644, 0o755)
128
125
        self.assertEqualMode(0o775, b.controldir._get_dir_mode())
129
126
        self.assertEqualMode(0o664, b.controldir._get_file_mode())
130
127
 
131
 
        with open('a', 'wb') as f:
132
 
            f.write(b'foo3\n')
 
128
        with open('a', 'wb') as f: f.write(b'foo3\n')
133
129
        t.commit('foo3')
134
130
        check_mode_r(self, '.bzr', 0o664, 0o775)
135
131
 
136
 
        with open('c', 'wb') as f:
137
 
            f.write(b'new c\n')
 
132
        with open('c', 'wb') as f: f.write(b'new c\n')
138
133
        t.add('c')
139
134
        t.commit('new c')
140
135
        check_mode_r(self, '.bzr', 0o664, 0o775)
162
157
        self.assertEqualMode(0o2775, b.controldir._get_dir_mode())
163
158
        self.assertEqualMode(0o664, b.controldir._get_file_mode())
164
159
 
165
 
        with open('a', 'wb') as f:
166
 
            f.write(b'foo4\n')
 
160
        with open('a', 'wb') as f: f.write(b'foo4\n')
167
161
        t.commit('foo4')
168
162
        check_mode_r(self, '.bzr', 0o664, 0o2775)
169
163
 
170
 
        with open('d', 'wb') as f:
171
 
            f.write(b'new d\n')
 
164
        with open('d', 'wb') as f: f.write(b'new d\n')
172
165
        t.add('d')
173
166
        t.commit('new d')
174
167
        check_mode_r(self, '.bzr', 0o664, 0o2775)
189
182
        os.mkdir('local')
190
183
        t_local = self.make_branch_and_tree('local')
191
184
        b_local = t_local.branch
192
 
        with open('local/a', 'wb') as f:
193
 
            f.write(b'foo\n')
 
185
        with open('local/a', 'wb') as f: f.write(b'foo\n')
194
186
        t_local.add('a')
195
187
        t_local.commit('foo')
196
188
 
220
212
        self.assertEqualMode(0o755, b_sftp.controldir._get_dir_mode())
221
213
        self.assertEqualMode(0o644, b_sftp.controldir._get_file_mode())
222
214
 
223
 
        with open('local/a', 'wb') as f:
224
 
            f.write(b'foo2\n')
 
215
        with open('local/a', 'wb') as f: f.write(b'foo2\n')
225
216
        t_local.commit('foo2')
226
217
        b_sftp.pull(b_local)
227
218
        # The mode should be maintained after commit
228
219
        check_mode_r(self, 'sftp/.bzr', 0o644, 0o755)
229
220
 
230
 
        with open('local/b', 'wb') as f:
231
 
            f.write(b'new b\n')
 
221
        with open('local/b', 'wb') as f: f.write(b'new b\n')
232
222
        t_local.add('b')
233
223
        t_local.commit('new b')
234
224
        b_sftp.pull(b_local)
245
235
        self.assertEqualMode(0o775, b_sftp.controldir._get_dir_mode())
246
236
        self.assertEqualMode(0o664, b_sftp.controldir._get_file_mode())
247
237
 
248
 
        with open('local/a', 'wb') as f:
249
 
            f.write(b'foo3\n')
 
238
        with open('local/a', 'wb') as f: f.write(b'foo3\n')
250
239
        t_local.commit('foo3')
251
240
        b_sftp.pull(b_local)
252
241
        check_mode_r(self, 'sftp/.bzr', 0o664, 0o775)
253
242
 
254
 
        with open('local/c', 'wb') as f:
255
 
            f.write(b'new c\n')
 
243
        with open('local/c', 'wb') as f: f.write(b'new c\n')
256
244
        t_local.add('c')
257
245
        t_local.commit('new c')
258
246
        b_sftp.pull(b_local)
270
258
            # Direct access should be masked by umask
271
259
            with t._sftp_open_exclusive('a', mode=0o666) as f:
272
260
                f.write(b'foo\n')
273
 
            self.assertTransportMode(t, 'a', 0o666 & ~umask)
 
261
            self.assertTransportMode(t, 'a', 0o666 &~umask)
274
262
 
275
263
            # but Transport overrides umask
276
264
            t.put_bytes('b', b'txt', mode=0o666)
277
265
            self.assertTransportMode(t, 'b', 0o666)
278
266
 
279
267
            t._get_sftp().mkdir('c', mode=0o777)
280
 
            self.assertTransportMode(t, 'c', 0o777 & ~umask)
 
268
            self.assertTransportMode(t, 'c', 0o777 &~umask)
281
269
 
282
270
            t.mkdir('d', mode=0o777)
283
271
            self.assertTransportMode(t, 'd', 0o777)