/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_commit.py

  • Committer: Jelmer Vernooij
  • Date: 2017-11-13 19:18:21 UTC
  • mfrom: (6813.1.1 py3_small_bits)
  • Revision ID: jelmer@jelmer.uk-20171113191821-rb33suwbp44cu5sa
Merge lp:~gz/brz/py3_small_bits

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
        """Commit and check two versions of a single file."""
87
87
        wt = self.make_branch_and_tree('.')
88
88
        b = wt.branch
89
 
        with file('hello', 'w') as f: f.write('hello world')
 
89
        with open('hello', 'w') as f: f.write('hello world')
90
90
        wt.add('hello')
91
91
        rev1 = wt.commit(message='add hello')
92
92
        file_id = wt.path2id('hello')
93
93
 
94
 
        with file('hello', 'w') as f: f.write('version 2')
 
94
        with open('hello', 'w') as f: f.write('version 2')
95
95
        rev2 = wt.commit(message='commit 2')
96
96
 
97
97
        eq = self.assertEqual
115
115
        """Attempt a lossy commit to a native branch."""
116
116
        wt = self.make_branch_and_tree('.')
117
117
        b = wt.branch
118
 
        with file('hello', 'w') as f: f.write('hello world')
 
118
        with open('hello', 'w') as f: f.write('hello world')
119
119
        wt.add('hello')
120
120
        revid = wt.commit(message='add hello', rev_id='revid', lossy=True)
121
121
        self.assertEqual('revid', revid)
126
126
        wt = self.make_branch_and_tree('.',
127
127
            format=test_foreign.DummyForeignVcsDirFormat())
128
128
        b = wt.branch
129
 
        with file('hello', 'w') as f: f.write('hello world')
 
129
        with open('hello', 'w') as f: f.write('hello world')
130
130
        wt.add('hello')
131
131
        revid = wt.commit(message='add hello', lossy=True,
132
132
            timestamp=1302659388, timezone=0)
139
139
            format=test_foreign.DummyForeignVcsDirFormat())
140
140
        wt = foreign_branch.create_checkout("local")
141
141
        b = wt.branch
142
 
        with file('local/hello', 'w') as f: f.write('hello world')
 
142
        with open('local/hello', 'w') as f: f.write('hello world')
143
143
        wt.add('hello')
144
144
        revid = wt.commit(message='add hello', lossy=True,
145
145
            timestamp=1302659388, timezone=0)
153
153
        """Test a commit with a missing file"""
154
154
        wt = self.make_branch_and_tree('.')
155
155
        b = wt.branch
156
 
        with file('hello', 'w') as f: f.write('hello world')
 
156
        with open('hello', 'w') as f: f.write('hello world')
157
157
        wt.add(['hello'], ['hello-id'])
158
158
        wt.commit(message='add hello')
159
159
 
191
191
        """Commit refuses unless there are changes or it's forced."""
192
192
        wt = self.make_branch_and_tree('.')
193
193
        b = wt.branch
194
 
        with file('hello', 'w') as f: f.write('hello')
 
194
        with open('hello', 'w') as f: f.write('hello')
195
195
        wt.add(['hello'])
196
196
        wt.commit(message='add hello')
197
197
        self.assertEqual(b.revno(), 1)
217
217
        """Selective commit in tree with deletions"""
218
218
        wt = self.make_branch_and_tree('.')
219
219
        b = wt.branch
220
 
        with file('hello', 'w') as f: f.write('hello')
221
 
        with file('buongia', 'w') as f: f.write('buongia')
 
220
        with open('hello', 'w') as f: f.write('hello')
 
221
        with open('buongia', 'w') as f: f.write('buongia')
222
222
        wt.add(['hello', 'buongia'],
223
223
              ['hello-id', 'buongia-id'])
224
224
        wt.commit(message='add files',
225
225
                 rev_id='test@rev-1')
226
226
 
227
227
        os.remove('hello')
228
 
        with file('buongia', 'w') as f: f.write('new text')
 
228
        with open('buongia', 'w') as f: f.write('new text')
229
229
        wt.commit(message='update text',
230
230
                 specific_files=['buongia'],
231
231
                 allow_pointless=False,
340
340
        """Commit with a removed file"""
341
341
        wt = self.make_branch_and_tree('.')
342
342
        b = wt.branch
343
 
        with file('hello', 'w') as f: f.write('hello world')
 
343
        with open('hello', 'w') as f: f.write('hello world')
344
344
        wt.add(['hello'], ['hello-id'])
345
345
        wt.commit(message='add hello')
346
346
        wt.remove('hello')
355
355
        b = wt.branch
356
356
        rev_ids = []
357
357
        for i in range(4):
358
 
            with file('hello', 'w') as f: f.write((str(i) * 4) + '\n')
 
358
            with open('hello', 'w') as f: f.write((str(i) * 4) + '\n')
359
359
            if i == 0:
360
360
                wt.add(['hello'], ['hello-id'])
361
361
            rev_id = 'test@rev-%d' % (i+1)
384
384
        from ..errors import StrictCommitFailed
385
385
        wt = self.make_branch_and_tree('.')
386
386
        b = wt.branch
387
 
        with file('hello', 'w') as f: f.write('hello world')
 
387
        with open('hello', 'w') as f: f.write('hello world')
388
388
        wt.add('hello')
389
 
        with file('goodbye', 'w') as f: f.write('goodbye cruel world!')
 
389
        with open('goodbye', 'w') as f: f.write('goodbye cruel world!')
390
390
        self.assertRaises(StrictCommitFailed, wt.commit,
391
391
            message='add hello but not goodbye', strict=True)
392
392
 
395
395
        should work."""
396
396
        wt = self.make_branch_and_tree('.')
397
397
        b = wt.branch
398
 
        with file('hello', 'w') as f: f.write('hello world')
 
398
        with open('hello', 'w') as f: f.write('hello world')
399
399
        wt.add('hello')
400
400
        wt.commit(message='add hello', strict=True)
401
401
 
403
403
        """Try and commit with unknown files and strict = False, should work."""
404
404
        wt = self.make_branch_and_tree('.')
405
405
        b = wt.branch
406
 
        with file('hello', 'w') as f: f.write('hello world')
 
406
        with open('hello', 'w') as f: f.write('hello world')
407
407
        wt.add('hello')
408
 
        with file('goodbye', 'w') as f: f.write('goodbye cruel world!')
 
408
        with open('goodbye', 'w') as f: f.write('goodbye cruel world!')
409
409
        wt.commit(message='add hello but not goodbye', strict=False)
410
410
 
411
411
    def test_nonstrict_commit_without_unknowns(self):
413
413
        should work."""
414
414
        wt = self.make_branch_and_tree('.')
415
415
        b = wt.branch
416
 
        with file('hello', 'w') as f: f.write('hello world')
 
416
        with open('hello', 'w') as f: f.write('hello world')
417
417
        wt.add('hello')
418
418
        wt.commit(message='add hello', strict=False)
419
419