169
168
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\"$")
191
170
def test_warn_about_forgotten_commit_message(self):
192
171
"""Test that the lack of -m parameter is caught"""
193
172
wt = self.make_branch_and_tree('.')
828
809
"""Ensure commit error if username is not set.
830
811
self.run_bzr(['init', 'foo'])
831
with open('foo/foo.txt', 'w') as f:
833
self.run_bzr(['add'], working_dir='foo')
813
open('foo.txt', 'w').write('hello')
814
self.run_bzr(['add'])
834
815
self.overrideEnv('EMAIL', None)
835
816
self.overrideEnv('BZR_EMAIL', None)
836
817
# Also, make sure that it's not inferred from mailname.
837
818
self.overrideAttr(config, '_auto_user_id',
838
819
lambda: (None, None))
840
['Unable to determine your name'],
841
['commit', '-m', 'initial'], working_dir='foo')
820
out, err = self.run_bzr(['commit', '-m', 'initial'], 3)
821
self.assertContainsRe(err, 'Unable to determine your name')
843
823
def test_commit_recursive_checkout(self):
844
824
"""Ensure that a commit to a recursive checkout fails cleanly.
846
826
self.run_bzr(['init', 'test_branch'])
847
827
self.run_bzr(['checkout', 'test_branch', 'test_checkout'])
848
self.run_bzr(['bind', '.'], working_dir='test_checkout') # bind to self
849
with open('test_checkout/foo.txt', 'w') as f:
851
self.run_bzr(['add'], working_dir='test_checkout')
852
out, err = self.run_bzr_error(
853
['Branch.*test_checkout.*appears to be bound to itself'],
854
['commit', '-m', 'addedfoo'], working_dir='test_checkout')
856
def test_mv_dirs_non_ascii(self):
857
"""Move directory with non-ascii name and containing files.
859
Regression test for bug 185211.
861
tree = self.make_branch_and_tree('.')
862
self.build_tree([u'abc\xa7/', u'abc\xa7/foo'])
864
tree.add([u'abc\xa7/', u'abc\xa7/foo'])
865
tree.commit('checkin')
867
tree.rename_one(u'abc\xa7','abc')
869
self.run_bzr('ci -m "non-ascii mv"')
872
class TestSmartServerCommit(TestCaseWithTransport):
874
def test_commit_to_lightweight(self):
875
self.setup_smart_server_with_call_log()
876
t = self.make_branch_and_tree('from')
877
for count in range(9):
878
t.commit(message='commit %d' % count)
879
out, err = self.run_bzr(['checkout', '--lightweight', self.get_url('from'),
881
self.reset_smart_call_log()
882
self.build_tree(['target/afile'])
883
self.run_bzr(['add', 'target/afile'])
884
out, err = self.run_bzr(['commit', '-m', 'do something', 'target'])
885
# This figure represent the amount of work to perform this use case. It
886
# is entirely ok to reduce this number if a test fails due to rpc_count
887
# being too low. If rpc_count increases, more network roundtrips have
888
# become necessary for this use case. Please do not adjust this number
889
# upwards without agreement from bzr's network support maintainers.
890
self.assertLength(211, self.hpss_calls)
891
self.assertLength(2, self.hpss_connections)
892
self.expectFailure("commit still uses VFS calls",
893
self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
828
os.chdir('test_checkout')
829
self.run_bzr(['bind', '.']) # bind to self
830
open('foo.txt', 'w').write('hello')
831
self.run_bzr(['add'])
832
out, err = self.run_bzr(['commit', '-m', 'addedfoo'], 3)
833
self.assertEqual(out, '')
834
self.assertContainsRe(err,
835
'Branch.*test_checkout.*appears to be bound to itself')