~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_permissions.py

  • Committer: Patch Queue Manager
  • Date: 2012-01-28 13:24:39 UTC
  • mfrom: (6450.1.1 bzr.dev)
  • Revision ID: pqm@pqm.ubuntu.com-20120128132439-phvlss4cq7bf5rji
(jelmer) Merge the 2.5 branch. (Jelmer Vernooij)

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
 
        open('a', 'wb').write('foo\n')
 
86
        with open('a', 'wb') as f: f.write('foo\n')
87
87
        # ensure check_mode_r works with capital-letter file-ids like TREE_ROOT
88
88
        t.add('a', 'CAPS-ID')
89
89
        t.commit('foo')
104
104
        self.assertEqualMode(0644, b.bzrdir._get_file_mode())
105
105
 
106
106
        # Modifying a file shouldn't break the permissions
107
 
        open('a', 'wb').write('foo2\n')
 
107
        with open('a', 'wb') as f: f.write('foo2\n')
108
108
        t.commit('foo2')
109
109
        # The mode should be maintained after commit
110
110
        check_mode_r(self, '.bzr', 0644, 0755)
111
111
 
112
112
        # Adding a new file should maintain the permissions
113
 
        open('b', 'wb').write('new b\n')
 
113
        with open('b', 'wb') as f: f.write('new b\n')
114
114
        t.add('b')
115
115
        t.commit('new b')
116
116
        check_mode_r(self, '.bzr', 0644, 0755)
125
125
        self.assertEqualMode(0775, b.bzrdir._get_dir_mode())
126
126
        self.assertEqualMode(0664, b.bzrdir._get_file_mode())
127
127
 
128
 
        open('a', 'wb').write('foo3\n')
 
128
        with open('a', 'wb') as f: f.write('foo3\n')
129
129
        t.commit('foo3')
130
130
        check_mode_r(self, '.bzr', 0664, 0775)
131
131
 
132
 
        open('c', 'wb').write('new c\n')
 
132
        with open('c', 'wb') as f: f.write('new c\n')
133
133
        t.add('c')
134
134
        t.commit('new c')
135
135
        check_mode_r(self, '.bzr', 0664, 0775)
157
157
        self.assertEqualMode(02775, b.bzrdir._get_dir_mode())
158
158
        self.assertEqualMode(0664, b.bzrdir._get_file_mode())
159
159
 
160
 
        open('a', 'wb').write('foo4\n')
 
160
        with open('a', 'wb') as f: f.write('foo4\n')
161
161
        t.commit('foo4')
162
162
        check_mode_r(self, '.bzr', 0664, 02775)
163
163
 
164
 
        open('d', 'wb').write('new d\n')
 
164
        with open('d', 'wb') as f: f.write('new d\n')
165
165
        t.add('d')
166
166
        t.commit('new d')
167
167
        check_mode_r(self, '.bzr', 0664, 02775)
182
182
        os.mkdir('local')
183
183
        t_local = self.make_branch_and_tree('local')
184
184
        b_local = t_local.branch
185
 
        open('local/a', 'wb').write('foo\n')
 
185
        with open('local/a', 'wb') as f: f.write('foo\n')
186
186
        t_local.add('a')
187
187
        t_local.commit('foo')
188
188
 
212
212
        self.assertEqualMode(0755, b_sftp.bzrdir._get_dir_mode())
213
213
        self.assertEqualMode(0644, b_sftp.bzrdir._get_file_mode())
214
214
 
215
 
        open('local/a', 'wb').write('foo2\n')
 
215
        with open('local/a', 'wb') as f: f.write('foo2\n')
216
216
        t_local.commit('foo2')
217
217
        b_sftp.pull(b_local)
218
218
        # The mode should be maintained after commit
219
219
        check_mode_r(self, 'sftp/.bzr', 0644, 0755)
220
220
 
221
 
        open('local/b', 'wb').write('new b\n')
 
221
        with open('local/b', 'wb') as f: f.write('new b\n')
222
222
        t_local.add('b')
223
223
        t_local.commit('new b')
224
224
        b_sftp.pull(b_local)
235
235
        self.assertEqualMode(0775, b_sftp.bzrdir._get_dir_mode())
236
236
        self.assertEqualMode(0664, b_sftp.bzrdir._get_file_mode())
237
237
 
238
 
        open('local/a', 'wb').write('foo3\n')
 
238
        with open('local/a', 'wb') as f: f.write('foo3\n')
239
239
        t_local.commit('foo3')
240
240
        b_sftp.pull(b_local)
241
241
        check_mode_r(self, 'sftp/.bzr', 0664, 0775)
242
242
 
243
 
        open('local/c', 'wb').write('new c\n')
 
243
        with open('local/c', 'wb') as f: f.write('new c\n')
244
244
        t_local.add('c')
245
245
        t_local.commit('new c')
246
246
        b_sftp.pull(b_local)