55
57
DocTestMatches("""\
59
aborting commit write group: PointlessCommit(No changes to commit)
57
60
bzr: ERROR: No changes to commit.\
58
61
Please 'bzr add' the files you want to commit,\
59
62
or use --unchanged to force an empty commit.
69
72
self.run_bzr(["commit", "--unchanged", "-m", u'foo\xb5'])
70
73
self.assertEqual('', self.run_bzr('unknowns')[0])
72
def test_commit_lossy_native(self):
73
"""A --lossy option to commit is supported."""
74
self.make_branch_and_tree('.')
75
self.run_bzr('commit --lossy --unchanged -m message')
76
self.assertEqual('', self.run_bzr('unknowns')[0])
78
def test_commit_lossy_foreign(self):
79
test_foreign.register_dummy_foreign_for_test(self)
80
self.make_branch_and_tree('.',
81
format=test_foreign.DummyForeignVcsDirFormat())
82
self.run_bzr('commit --lossy --unchanged -m message')
83
output = self.run_bzr('revision-info')[0]
84
self.assertTrue(output.startswith('1 dummy-'))
86
75
def test_commit_with_path(self):
87
76
"""Commit tree with path of root specified"""
88
77
a_tree = self.make_branch_and_tree('a')
102
91
self.run_bzr('resolved b/a_file')
103
92
self.run_bzr(['commit', '-m', 'merge into b', 'b'])
105
95
def test_10_verbose_commit(self):
106
96
"""Add one file and examine verbose commit output"""
107
97
tree = self.make_branch_and_tree('.')
135
125
def test_unicode_commit_message_is_filename(self):
136
126
"""Unicode commit message same as a filename (Bug #563646).
138
self.requireFeature(features.UnicodeFilenameFeature)
128
self.requireFeature(UnicodeFilenameFeature)
139
129
file_name = u'\N{euro sign}'
140
130
self.run_bzr(['init'])
141
131
open(file_name, 'w').write('hello world')
329
319
tree = self.make_branch_and_tree('.')
330
320
self.build_tree_contents([('foo.c', 'int main() {}')])
331
321
tree.add('foo.c')
332
self.run_bzr('commit -m ""')
322
self.run_bzr('commit -m ""', retcode=3)
324
def test_unsupported_encoding_commit_message(self):
325
if sys.platform == 'win32':
326
raise tests.TestNotApplicable('Win32 parses arguments directly'
327
' as Unicode, so we can\'t pass invalid non-ascii')
328
tree = self.make_branch_and_tree('.')
329
self.build_tree_contents([('foo.c', 'int main() {}')])
331
# LANG env variable has no effect on Windows
332
# but some characters anyway cannot be represented
333
# in default user encoding
334
char = probe_bad_non_ascii(osutils.get_user_encoding())
336
raise TestSkipped('Cannot find suitable non-ascii character'
337
'for user_encoding (%s)' % osutils.get_user_encoding())
338
out,err = self.run_bzr_subprocess('commit -m "%s"' % char,
340
env_changes={'LANG': 'C'})
341
self.assertContainsRe(err, r'bzrlib.errors.BzrError: Parameter.*is '
342
'unsupported by the current encoding.')
334
344
def test_other_branch_commit(self):
335
345
# this branch is to ensure consistent behaviour, whether we're run
596
606
'commit -m add-b --fixes=xxx:123',
597
607
working_dir='tree')
599
def test_fixes_bug_with_default_tracker(self):
600
"""commit --fixes=234 uses the default bug tracker."""
601
tree = self.make_branch_and_tree('tree')
602
self.build_tree(['tree/hello.txt'])
603
tree.add('hello.txt')
605
["bzr: ERROR: No tracker specified for bug 123. Use the form "
606
"'tracker:id' or specify a default bug tracker using the "
607
"`bugtracker` option.\n"
608
"See \"bzr help bugs\" for more information on this feature. "
610
'commit -m add-b --fixes=123',
612
tree.branch.get_config().set_user_option("bugtracker", "lp")
613
self.run_bzr('commit -m hello --fixes=234 tree/hello.txt')
614
last_rev = tree.branch.repository.get_revision(tree.last_revision())
615
self.assertEqual('https://launchpad.net/bugs/234 fixed',
616
last_rev.properties['bugs'])
618
609
def test_fixes_invalid_bug_number(self):
619
610
tree = self.make_branch_and_tree('tree')
620
611
self.build_tree(['tree/hello.txt'])
632
623
self.build_tree(['tree/hello.txt'])
633
624
tree.add('hello.txt')
634
625
self.run_bzr_error(
635
[r"Invalid bug orange:apples:bananas. Must be in the form of "
636
r"'tracker:id'\. See \"bzr help bugs\" for more information on "
637
r"this feature.\nCommit refused\."],
638
'commit -m add-b --fixes=orange:apples:bananas',
626
[r"Invalid bug orange. Must be in the form of 'tracker:id'\. "
627
r"See \"bzr help bugs\" for more information on this feature.\n"
628
r"Commit refused\."],
629
'commit -m add-b --fixes=orange',
639
630
working_dir='tree')
641
632
def test_no_author(self):
757
748
tree.add('hello.txt')
760
def test_edit_empty_message(self):
761
tree = self.make_branch_and_tree('tree')
763
self.build_tree(['tree/hello.txt'])
764
tree.add('hello.txt')
765
out, err = self.run_bzr("commit tree/hello.txt", retcode=3,
767
self.assertContainsRe(err,
768
"bzr: ERROR: Empty commit message specified")
770
751
def test_commit_hook_template_accepted(self):
771
752
tree = self.setup_commit_with_template()
772
753
out, err = self.run_bzr("commit tree/hello.txt", stdin="y\n")
776
757
def test_commit_hook_template_rejected(self):
777
758
tree = self.setup_commit_with_template()
778
759
expected = tree.last_revision()
779
out, err = self.run_bzr_error(["Empty commit message specified."
780
" Please specify a commit message with either"
781
" --message or --file or leave a blank message"
782
" with --message \"\"."],
760
out, err = self.run_bzr_error(["empty commit message"],
783
761
"commit tree/hello.txt", stdin="n\n")
784
762
self.assertEqual(expected, tree.last_revision())
786
def test_set_commit_message(self):
787
msgeditor.hooks.install_named_hook("set_commit_message",
788
lambda commit_obj, msg: "save me some typing\n", None)
789
tree = self.make_branch_and_tree('tree')
790
self.build_tree(['tree/hello.txt'])
791
tree.add('hello.txt')
792
out, err = self.run_bzr("commit tree/hello.txt")
793
last_rev = tree.branch.repository.get_revision(tree.last_revision())
794
self.assertEqual('save me some typing\n', last_rev.message)
796
764
def test_commit_without_username(self):
797
765
"""Ensure commit error if username is not set.