~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

[patch] use unicode literals for all hardcoded paths (Alexander Belchenko)

> When you use flat string on Windows for base part of file names then all
> derived file names is always representing as flat string. On Linux/Cygwin as
> I can see in situations when path cannot be represented as flat string (or in
> ascii encoding?) it silently converted to unicode. As result we have
> different behaviour with non-ascii (non-english) file names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
    def test_simple_commit(self):
49
49
        """Commit and check two versions of a single file."""
50
 
        b = Branch.initialize('.')
 
50
        b = Branch.initialize(u'.')
51
51
        file('hello', 'w').write('hello world')
52
52
        b.working_tree().add('hello')
53
53
        b.working_tree().commit(message='add hello')
71
71
 
72
72
    def test_delete_commit(self):
73
73
        """Test a commit with a deleted file"""
74
 
        b = Branch.initialize('.')
 
74
        b = Branch.initialize(u'.')
75
75
        file('hello', 'w').write('hello world')
76
76
        b.working_tree().add(['hello'], ['hello-id'])
77
77
        b.working_tree().commit(message='add hello')
84
84
 
85
85
    def test_pointless_commit(self):
86
86
        """Commit refuses unless there are changes or it's forced."""
87
 
        b = Branch.initialize('.')
 
87
        b = Branch.initialize(u'.')
88
88
        file('hello', 'w').write('hello')
89
89
        b.working_tree().add(['hello'])
90
90
        b.working_tree().commit(message='add hello')
97
97
        
98
98
    def test_commit_empty(self):
99
99
        """Commiting an empty tree works."""
100
 
        b = Branch.initialize('.')
 
100
        b = Branch.initialize(u'.')
101
101
        b.working_tree().commit(message='empty tree', allow_pointless=True)
102
102
        self.assertRaises(PointlessCommit,
103
103
                          b.working_tree().commit,
109
109
 
110
110
    def test_selective_delete(self):
111
111
        """Selective commit in tree with deletions"""
112
 
        b = Branch.initialize('.')
 
112
        b = Branch.initialize(u'.')
113
113
        file('hello', 'w').write('hello')
114
114
        file('buongia', 'w').write('buongia')
115
115
        b.working_tree().add(['hello', 'buongia'],
144
144
 
145
145
    def test_commit_rename(self):
146
146
        """Test commit of a revision where a file is renamed."""
147
 
        b = Branch.initialize('.')
148
 
        tree = WorkingTree('.', b)
 
147
        b = Branch.initialize(u'.')
 
148
        tree = WorkingTree(u'.', b)
149
149
        self.build_tree(['hello'], line_endings='binary')
150
150
        tree.add(['hello'], ['hello-id'])
151
151
        tree.commit(message='one', rev_id='test@rev-1', allow_pointless=False)
171
171
 
172
172
    def test_reused_rev_id(self):
173
173
        """Test that a revision id cannot be reused in a branch"""
174
 
        b = Branch.initialize('.')
 
174
        b = Branch.initialize(u'.')
175
175
        b.working_tree().commit('initial', rev_id='test@rev-1', allow_pointless=True)
176
176
        self.assertRaises(Exception,
177
177
                          b.working_tree().commit,
182
182
    def test_commit_move(self):
183
183
        """Test commit of revisions with moved files and directories"""
184
184
        eq = self.assertEquals
185
 
        b = Branch.initialize('.')
 
185
        b = Branch.initialize(u'.')
186
186
        r1 = 'test@rev-1'
187
187
        self.build_tree(['hello', 'a/', 'b/'])
188
188
        b.working_tree().add(['hello', 'a', 'b'], ['hello-id', 'a-id', 'b-id'])
215
215
        
216
216
    def test_removed_commit(self):
217
217
        """Commit with a removed file"""
218
 
        b = Branch.initialize('.')
 
218
        b = Branch.initialize(u'.')
219
219
        wt = b.working_tree()
220
220
        file('hello', 'w').write('hello world')
221
221
        b.working_tree().add(['hello'], ['hello-id'])
231
231
 
232
232
    def test_committed_ancestry(self):
233
233
        """Test commit appends revisions to ancestry."""
234
 
        b = Branch.initialize('.')
 
234
        b = Branch.initialize(u'.')
235
235
        rev_ids = []
236
236
        for i in range(4):
237
237
            file('hello', 'w').write((str(i) * 4) + '\n')
248
248
            eq(anc, [None] + rev_ids[:i+1])
249
249
 
250
250
    def test_commit_new_subdir_child_selective(self):
251
 
        b = Branch.initialize('.')
 
251
        b = Branch.initialize(u'.')
252
252
        self.build_tree(['dir/', 'dir/file1', 'dir/file2'])
253
253
        b.working_tree().add(['dir', 'dir/file1', 'dir/file2'],
254
254
              ['dirid', 'file1id', 'file2id'])
262
262
    def test_strict_commit(self):
263
263
        """Try and commit with unknown files and strict = True, should fail."""
264
264
        from bzrlib.errors import StrictCommitFailed
265
 
        b = Branch.initialize('.')
 
265
        b = Branch.initialize(u'.')
266
266
        file('hello', 'w').write('hello world')
267
267
        b.working_tree().add('hello')
268
268
        file('goodbye', 'w').write('goodbye cruel world!')
273
273
        """Try and commit with no unknown files and strict = True,
274
274
        should work."""
275
275
        from bzrlib.errors import StrictCommitFailed
276
 
        b = Branch.initialize('.')
 
276
        b = Branch.initialize(u'.')
277
277
        file('hello', 'w').write('hello world')
278
278
        b.working_tree().add('hello')
279
279
        b.working_tree().commit(message='add hello', strict=True)
280
280
 
281
281
    def test_nonstrict_commit(self):
282
282
        """Try and commit with unknown files and strict = False, should work."""
283
 
        b = Branch.initialize('.')
 
283
        b = Branch.initialize(u'.')
284
284
        file('hello', 'w').write('hello world')
285
285
        b.working_tree().add('hello')
286
286
        file('goodbye', 'w').write('goodbye cruel world!')
289
289
    def test_nonstrict_commit_without_unknowns(self):
290
290
        """Try and commit with no unknown files and strict = False,
291
291
        should work."""
292
 
        b = Branch.initialize('.')
 
292
        b = Branch.initialize(u'.')
293
293
        file('hello', 'w').write('hello world')
294
294
        b.working_tree().add('hello')
295
295
        b.working_tree().commit(message='add hello', strict=False)
298
298
        import bzrlib.gpg
299
299
        import bzrlib.commit as commit
300
300
        oldstrategy = bzrlib.gpg.GPGStrategy
301
 
        branch = Branch.initialize('.')
 
301
        branch = Branch.initialize(u'.')
302
302
        branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
303
303
        self.failIf(branch.revision_store.has_id('A', 'sig'))
304
304
        try:
317
317
        import bzrlib.gpg
318
318
        import bzrlib.commit as commit
319
319
        oldstrategy = bzrlib.gpg.GPGStrategy
320
 
        branch = Branch.initialize('.')
 
320
        branch = Branch.initialize(u'.')
321
321
        branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
322
322
        self.failIf(branch.revision_store.has_id('A', 'sig'))
323
323
        try:
330
330
                              branch, "base",
331
331
                              allow_pointless=True,
332
332
                              rev_id='B')
333
 
            branch = Branch.open('.')
 
333
            branch = Branch.open(u'.')
334
334
            self.assertEqual(branch.revision_history(), ['A'])
335
335
            self.failIf(branch.revision_store.has_id('B'))
336
336
        finally:
338
338
 
339
339
    def test_commit_invokes_hooks(self):
340
340
        import bzrlib.commit as commit
341
 
        branch = Branch.initialize('.')
 
341
        branch = Branch.initialize(u'.')
342
342
        calls = []
343
343
        def called(branch, rev_id):
344
344
            calls.append('called')