~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2012-01-28 12:47:17 UTC
  • mfrom: (6437.3.28 2.5)
  • mto: This revision was merged to the branch mainline in revision 6451.
  • Revision ID: jelmer@canonical.com-20120128124717-80ggi7q1y7m2wjf0
MergeĀ 2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
    def test_bound_commit(self):
104
104
        b_base, wt_child = self.create_branches()
105
105
 
106
 
        open('child/a', 'wb').write('new contents\n')
 
106
        with open('child/a', 'wb') as f: f.write('new contents\n')
107
107
        wt_child.commit('modified a', rev_id='r@c-2')
108
108
 
109
109
        self.assertEqual(['r@b-1', 'r@c-2'], wt_child.branch.revision_history())
113
113
        # Make sure commit fails if out of date.
114
114
        b_base, wt_child = self.create_branches()
115
115
 
116
 
        open('base/a', 'wb').write('new base contents\n')
 
116
        with open('base/a', 'wb') as f: f.write('new base contents\n')
117
117
        b_base.bzrdir.open_workingtree().commit('base', rev_id='r@b-2')
118
118
 
119
 
        open('child/b', 'wb').write('new b child contents\n')
 
119
        with open('child/b', 'wb') as f: f.write('new b child contents\n')
120
120
        self.assertRaises(errors.BoundBranchOutOfDate,
121
121
                wt_child.commit, 'child', rev_id='r@c-2')
122
122
 
139
139
 
140
140
        wt_child2 = wt_child.branch.create_checkout('child2')
141
141
 
142
 
        open('child2/a', 'wb').write('new contents\n')
 
142
        with open('child2/a', 'wb') as f: f.write('new contents\n')
143
143
        self.assertRaises(errors.CommitToDoubleBoundBranch,
144
144
                wt_child2.commit, 'child2', rev_id='r@d-2')
145
145
 
153
153
        __unused_t = self.get_transport()
154
154
 
155
155
        wt_base = b_base.bzrdir.open_workingtree()
156
 
        open('base/a', 'wb').write('new base contents\n')
 
156
        with open('base/a', 'wb') as f: f.write('new base contents\n')
157
157
        wt_base.commit('base', rev_id='r@b-2')
158
158
 
159
 
        open('child/b', 'wb').write('new b child contents\n')
 
159
        with open('child/b', 'wb') as f: f.write('new b child contents\n')
160
160
        self.assertRaises(errors.BoundBranchOutOfDate,
161
161
                wt_child.commit, 'child', rev_id='r@c-2')
162
162
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
181
181
 
182
182
        sftp_b_base.bind(sftp_b_newbase)
183
183
 
184
 
        open('child/a', 'wb').write('new contents\n')
 
184
        with open('child/a', 'wb') as f: f.write('new contents\n')
185
185
        self.assertRaises(errors.CommitToDoubleBoundBranch,
186
186
                wt_child.commit, 'failure', rev_id='r@c-2')
187
187
 
193
193
        b_base, wt_child = self.create_branches()
194
194
 
195
195
        wt_child.branch.unbind()
196
 
        open('child/a', 'ab').write('child contents\n')
 
196
        with open('child/a', 'ab') as f: f.write('child contents\n')
197
197
        wt_child_rev = wt_child.commit('child', rev_id='r@c-2')
198
198
 
199
199
        self.assertEqual(['r@b-1', 'r@c-2'], wt_child.branch.revision_history())
200
200
        self.assertEqual(['r@b-1'], b_base.revision_history())
201
201
 
202
 
        open('base/b', 'ab').write('base contents\n')
 
202
        with open('base/b', 'ab') as f: f.write('base contents\n')
203
203
        b_base.bzrdir.open_workingtree().commit('base', rev_id='r@b-2')
204
204
        self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history())
205
205
 
225
225
 
226
226
        wt_child.branch.unbind()
227
227
 
228
 
        open('a', 'ab').write('base changes\n')
 
228
        with open('a', 'ab') as f: f.write('base changes\n')
229
229
        wt_base = b_base.bzrdir.open_workingtree()
230
230
        wt_base.commit('base', rev_id='r@b-2')
231
231
        self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history())
288
288
 
289
289
        wt_other = wt_child.bzrdir.sprout('other').open_workingtree()
290
290
 
291
 
        open('other/c', 'wb').write('file c\n')
 
291
        with open('other/c', 'wb') as f: f.write('file c\n')
292
292
        wt_other.add('c')
293
293
        wt_other.commit('adding c', rev_id='r@d-2')
294
294
 
312
312
    def test_commit_fails(self):
313
313
        b_base, wt_child = self.create_branches()
314
314
 
315
 
        open('a', 'ab').write('child adds some text\n')
 
315
        with open('a', 'ab') as f: f.write('child adds some text\n')
316
316
 
317
317
        # this deletes the branch from memory
318
318
        del b_base