38
35
# If forced, it should succeed, but this is not tested here.
39
36
self.run_bzr("init")
40
37
self.build_tree(['hello.txt'])
41
out,err = self.run_bzr("commit", "-m", "empty", retcode=3)
42
self.assertEqual('', out)
43
self.assertStartsWith(err, 'bzr: ERROR: no changes to commit.'
44
' use --unchanged to commit anyhow\n')
46
def test_commit_success(self):
47
"""Successful commit should not leave behind a bzr-commit-* file"""
49
self.run_bzr("commit", "--unchanged", "-m", "message")
50
self.assertEqual('', self.capture('unknowns'))
52
# same for unicode messages
53
self.run_bzr("commit", "--unchanged", "-m", u'foo\xb5')
54
self.assertEqual('', self.capture('unknowns'))
38
result = self.run_bzr("commit", "-m", "empty", retcode=3)
39
self.assertEqual(('', 'bzr: ERROR: no changes to commit.'
40
' use --unchanged to commit anyhow\n'),
56
43
def test_commit_with_path(self):
57
44
"""Commit tree with path of root specified"""
313
300
self.assertNotContainsRe(result, 'file-a')
314
301
result = self.run_bzr('status')[0]
315
302
self.assertContainsRe(result, 'removed:\n file-a')
317
def test_strict_commit(self):
318
"""Commit with --strict works if everything is known"""
319
ignores._set_user_ignores([])
320
tree = self.make_branch_and_tree('tree')
321
self.build_tree(['tree/a'])
323
# A simple change should just work
324
self.run_bzr('commit', '--strict', '-m', 'adding a',
327
def test_strict_commit_no_changes(self):
328
"""commit --strict gives "no changes" if there is nothing to commit"""
329
tree = self.make_branch_and_tree('tree')
330
self.build_tree(['tree/a'])
332
tree.commit('adding a')
334
# With no changes, it should just be 'no changes'
335
# Make sure that commit is failing because there is nothing to do
336
self.run_bzr_error(['no changes to commit'],
337
'commit', '--strict', '-m', 'no changes',
340
# But --strict doesn't care if you supply --unchanged
341
self.run_bzr('commit', '--strict', '--unchanged', '-m', 'no changes',
344
def test_strict_commit_unknown(self):
345
"""commit --strict fails if a file is unknown"""
346
tree = self.make_branch_and_tree('tree')
347
self.build_tree(['tree/a'])
349
tree.commit('adding a')
351
# Add one file so there is a change, but forget the other
352
self.build_tree(['tree/b', 'tree/c'])
354
self.run_bzr_error(['Commit refused because there are unknown files'],
355
'commit', '--strict', '-m', 'add b',
358
# --no-strict overrides --strict
359
self.run_bzr('commit', '--strict', '-m', 'add b', '--no-strict',