248
248
# LANG env variable has no effect on Windows
249
249
# but some characters anyway cannot be represented
250
250
# in default user encoding
251
char = probe_bad_non_ascii(osutils.get_user_encoding())
251
char = probe_bad_non_ascii(bzrlib.user_encoding)
253
253
raise TestSkipped('Cannot find suitable non-ascii character'
254
'for user_encoding (%s)' % osutils.get_user_encoding())
254
'for user_encoding (%s)' % bzrlib.user_encoding)
255
255
out,err = self.run_bzr_subprocess('commit -m "%s"' % char,
257
257
env_changes={'LANG': 'C'})
331
331
self.build_tree_contents([('u1/hosts', 'merge resolution\n')])
332
332
self.run_bzr('commit -m checkin-merge-of-the-offline-work-from-u1 u1')
334
def test_commit_exclude_excludes_modified_files(self):
335
"""Commit -x foo should ignore changes to foo."""
336
tree = self.make_branch_and_tree('.')
337
self.build_tree(['a', 'b', 'c'])
338
tree.smart_add(['.'])
339
out, err = self.run_bzr(['commit', '-m', 'test', '-x', 'b'])
340
self.assertFalse('added b' in out)
341
self.assertFalse('added b' in err)
342
# If b was excluded it will still be 'added' in status.
343
out, err = self.run_bzr(['added'])
344
self.assertEqual('b\n', out)
345
self.assertEqual('', err)
347
def test_commit_exclude_twice_uses_both_rules(self):
348
"""Commit -x foo -x bar should ignore changes to foo and bar."""
349
tree = self.make_branch_and_tree('.')
350
self.build_tree(['a', 'b', 'c'])
351
tree.smart_add(['.'])
352
out, err = self.run_bzr(['commit', '-m', 'test', '-x', 'b', '-x', 'c'])
353
self.assertFalse('added b' in out)
354
self.assertFalse('added c' in out)
355
self.assertFalse('added b' in err)
356
self.assertFalse('added c' in err)
357
# If b was excluded it will still be 'added' in status.
358
out, err = self.run_bzr(['added'])
359
self.assertTrue('b\n' in out)
360
self.assertTrue('c\n' in out)
361
self.assertEqual('', err)
363
334
def test_commit_respects_spec_for_removals(self):
364
335
"""Commit with a file spec should only commit removals that match"""
365
336
t = self.make_branch_and_tree('.')
549
520
tree = self.make_branch_and_tree('tree')
550
521
self.build_tree(['tree/hello.txt'])
551
522
tree.add('hello.txt')
552
self.run_bzr(["commit", '-m', 'hello',
553
'--author', u'John D\xf6 <jdoe@example.com>',
523
self.run_bzr("commit -m hello --author='John Doe <jdoe@example.com>' "
555
525
last_rev = tree.branch.repository.get_revision(tree.last_revision())
556
526
properties = last_rev.properties
557
self.assertEqual(u'John D\xf6 <jdoe@example.com>', properties['author'])
527
self.assertEqual('John Doe <jdoe@example.com>', properties['author'])
559
529
def test_author_no_email(self):
560
530
"""Author's name without an email address is allowed, too."""
597
567
self.assertContainsRe(err,
598
568
r'^bzr: ERROR: Cannot lock.*readonly transport')
600
def test_commit_hook_template(self):
601
# Test that commit template hooks work
602
def restoreDefaults():
603
msgeditor.hooks['commit_message_template'] = []
604
osutils.set_or_unset_env('BZR_EDITOR', default_editor)
605
if sys.platform == "win32":
606
f = file('fed.bat', 'w')
607
f.write('@rem dummy fed')
609
default_editor = osutils.set_or_unset_env('BZR_EDITOR', "fed.bat")
611
f = file('fed.sh', 'wb')
612
f.write('#!/bin/sh\n')
614
os.chmod('fed.sh', 0755)
615
default_editor = osutils.set_or_unset_env('BZR_EDITOR', "./fed.sh")
616
self.addCleanup(restoreDefaults)
617
msgeditor.hooks.install_named_hook("commit_message_template",
618
lambda commit_obj, msg: "save me some typing\n", None)
619
tree = self.make_branch_and_tree('tree')
620
self.build_tree(['tree/hello.txt'])
621
tree.add('hello.txt')
622
out, err = self.run_bzr("commit tree/hello.txt")
623
last_rev = tree.branch.repository.get_revision(tree.last_revision())
624
self.assertEqual('save me some typing\n', last_rev.message)