35
38
# If forced, it should succeed, but this is not tested here.
36
39
self.run_bzr("init")
37
40
self.build_tree(['hello.txt'])
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'),
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'))
43
56
def test_commit_with_path(self):
44
57
"""Commit tree with path of root specified"""
300
313
self.assertNotContainsRe(result, 'file-a')
301
314
result = self.run_bzr('status')[0]
302
315
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',