1
# Copyright (C) 2005, 2006 by Canonical Ltd
1
# Copyright (C) 2005, 2006 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33
36
def test_05_empty_commit(self):
34
37
"""Commit of tree with no versioned files should fail"""
35
38
# If forced, it should succeed, but this is not tested here.
37
40
self.build_tree(['hello.txt'])
38
self.runbzr("commit -m empty", retcode=3)
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'))
40
56
def test_commit_with_path(self):
41
57
"""Commit tree with path of root specified"""
284
300
# version or the u2 version.
285
301
self.build_tree_contents([('u1/hosts', 'merge resolution\n')])
286
302
self.run_bzr('commit', '-m', 'checkin merge of the offline work from u1', 'u1')
304
def test_commit_respects_spec_for_removals(self):
305
"""Commit with a file spec should only commit removals that match"""
306
t = self.make_branch_and_tree('.')
307
self.build_tree(['file-a', 'dir-a/', 'dir-a/file-b'])
308
t.add(['file-a', 'dir-a', 'dir-a/file-b'])
310
t.remove(['file-a', 'dir-a/file-b'])
312
result = self.run_bzr('commit', '.', '-m' 'removed file-b')[1]
313
self.assertNotContainsRe(result, 'file-a')
314
result = self.run_bzr('status')[0]
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',