168
169
osutils.get_terminal_encoding = default_get_terminal_enc
171
def test_non_ascii_file_unversioned_utf8(self):
172
self.requireFeature(features.UnicodeFilenameFeature)
173
tree = self.make_branch_and_tree(".")
174
self.build_tree(["f"])
176
out, err = self.run_bzr(["commit", "-m", "Wrong filename", u"\xa7"],
177
encoding="utf-8", retcode=3)
178
self.assertContainsRe(err, "(?m)not versioned: \"\xc2\xa7\"$")
180
def test_non_ascii_file_unversioned_iso_8859_5(self):
181
self.requireFeature(features.UnicodeFilenameFeature)
182
tree = self.make_branch_and_tree(".")
183
self.build_tree(["f"])
185
out, err = self.run_bzr(["commit", "-m", "Wrong filename", u"\xa7"],
186
encoding="iso-8859-5", retcode=3)
187
self.expectFailure("Error messages are always written as UTF-8",
188
self.assertNotContainsString, err, "\xc2\xa7")
189
self.assertContainsRe(err, "(?m)not versioned: \"\xfd\"$")
170
191
def test_warn_about_forgotten_commit_message(self):
171
192
"""Test that the lack of -m parameter is caught"""
172
193
wt = self.make_branch_and_tree('.')
694
713
self.assertEqual(
695
714
'Sat 2009-10-10 08:00:00 +0100',
696
715
osutils.format_date(last_rev.timestamp, last_rev.timezone))
717
def test_commit_time_negative_windows(self):
718
tree = self.make_branch_and_tree('tree')
719
self.build_tree(['tree/hello.txt'])
720
tree.add('hello.txt')
721
out, err = self.run_bzr("commit -m hello "
722
"--commit-time='1969-10-10 00:00:00 +0000' tree/hello.txt")
723
last_rev = tree.branch.repository.get_revision(tree.last_revision())
725
'Fri 1969-10-10 00:00:00 +0000',
726
osutils.format_date(last_rev.timestamp, last_rev.timezone))
728
def test_commit_time_negative_32bit(self):
729
tree = self.make_branch_and_tree('tree')
730
self.build_tree(['tree/hello.txt'])
731
tree.add('hello.txt')
732
out, err = self.run_bzr("commit -m hello "
733
"--commit-time='1900-01-01 00:00:00 +0000' tree/hello.txt")
734
last_rev = tree.branch.repository.get_revision(tree.last_revision())
736
'Mon 1900-01-01 00:00:00 +0000',
737
osutils.format_date(last_rev.timestamp, last_rev.timezone))
739
def test_commit_time_positive_32bit(self):
740
tree = self.make_branch_and_tree('tree')
741
self.build_tree(['tree/hello.txt'])
742
tree.add('hello.txt')
743
out, err = self.run_bzr("commit -m hello "
744
"--commit-time='2039-01-01 00:00:00 +0000' tree/hello.txt")
745
last_rev = tree.branch.repository.get_revision(tree.last_revision())
747
'Sat 2039-01-01 00:00:00 +0000',
748
osutils.format_date(last_rev.timestamp, last_rev.timezone))
698
750
def test_commit_time_bad_time(self):
699
751
tree = self.make_branch_and_tree('tree')
700
752
self.build_tree(['tree/hello.txt'])
704
756
self.assertStartsWith(
705
757
err, "bzr: ERROR: Could not parse --commit-time:")
759
def test_commit_time_missing_tz(self):
760
tree = self.make_branch_and_tree('tree')
761
self.build_tree(['tree/hello.txt'])
762
tree.add('hello.txt')
763
out, err = self.run_bzr("commit -m hello "
764
"--commit-time='2009-10-10 08:00:00' tree/hello.txt", retcode=3)
765
self.assertStartsWith(
766
err, "bzr: ERROR: Could not parse --commit-time:")
767
# Test that it is actually checking and does not simply crash with
768
# some other exception
769
self.assertContainsString(err, "missing a timezone offset")
707
771
def test_partial_commit_with_renames_in_tree(self):
708
772
# this test illustrates bug #140419
709
773
t = self.make_branch_and_tree('.')
797
861
"""Ensure commit error if username is not set.
799
863
self.run_bzr(['init', 'foo'])
801
open('foo.txt', 'w').write('hello')
802
self.run_bzr(['add'])
864
with open('foo/foo.txt', 'w') as f:
866
self.run_bzr(['add'], working_dir='foo')
803
867
self.overrideEnv('EMAIL', None)
804
868
self.overrideEnv('BZR_EMAIL', None)
805
869
# Also, make sure that it's not inferred from mailname.
806
870
self.overrideAttr(config, '_auto_user_id',
807
871
lambda: (None, None))
808
out, err = self.run_bzr(['commit', '-m', 'initial'], 3)
809
self.assertContainsRe(err, 'Unable to determine your name')
873
['Unable to determine your name'],
874
['commit', '-m', 'initial'], working_dir='foo')
811
876
def test_commit_recursive_checkout(self):
812
877
"""Ensure that a commit to a recursive checkout fails cleanly.
814
879
self.run_bzr(['init', 'test_branch'])
815
880
self.run_bzr(['checkout', 'test_branch', 'test_checkout'])
816
os.chdir('test_checkout')
817
self.run_bzr(['bind', '.']) # bind to self
818
open('foo.txt', 'w').write('hello')
819
self.run_bzr(['add'])
820
out, err = self.run_bzr(['commit', '-m', 'addedfoo'], 3)
821
self.assertEqual(out, '')
822
self.assertContainsRe(err,
823
'Branch.*test_checkout.*appears to be bound to itself')
881
self.run_bzr(['bind', '.'], working_dir='test_checkout') # bind to self
882
with open('test_checkout/foo.txt', 'w') as f:
884
self.run_bzr(['add'], working_dir='test_checkout')
885
out, err = self.run_bzr_error(
886
['Branch.*test_checkout.*appears to be bound to itself'],
887
['commit', '-m', 'addedfoo'], working_dir='test_checkout')
889
def test_mv_dirs_non_ascii(self):
890
"""Move directory with non-ascii name and containing files.
892
Regression test for bug 185211.
894
tree = self.make_branch_and_tree('.')
895
self.build_tree([u'abc\xa7/', u'abc\xa7/foo'])
897
tree.add([u'abc\xa7/', u'abc\xa7/foo'])
898
tree.commit('checkin')
900
tree.rename_one(u'abc\xa7','abc')
902
self.run_bzr('ci -m "non-ascii mv"')
905
class TestSmartServerCommit(TestCaseWithTransport):
907
def test_commit_to_lightweight(self):
908
self.setup_smart_server_with_call_log()
909
t = self.make_branch_and_tree('from')
910
for count in range(9):
911
t.commit(message='commit %d' % count)
912
out, err = self.run_bzr(['checkout', '--lightweight', self.get_url('from'),
914
self.reset_smart_call_log()
915
self.build_tree(['target/afile'])
916
self.run_bzr(['add', 'target/afile'])
917
out, err = self.run_bzr(['commit', '-m', 'do something', 'target'])
918
# This figure represent the amount of work to perform this use case. It
919
# is entirely ok to reduce this number if a test fails due to rpc_count
920
# being too low. If rpc_count increases, more network roundtrips have
921
# become necessary for this use case. Please do not adjust this number
922
# upwards without agreement from bzr's network support maintainers.
923
self.assertLength(211, self.hpss_calls)
924
self.assertLength(2, self.hpss_connections)
925
self.expectFailure("commit still uses VFS calls",
926
self.assertThat, self.hpss_calls, ContainsNoVfsCalls)