~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_commit.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-05 16:03:11 UTC
  • mfrom: (6432 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6433.
  • Revision ID: jelmer@samba.org-20120105160311-12o5p67kin1v3zps
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    features,
37
37
    )
38
38
from bzrlib.tests import TestCaseWithTransport
 
39
from bzrlib.tests.matchers import ContainsNoVfsCalls
39
40
 
40
41
 
41
42
class TestCommit(TestCaseWithTransport):
167
168
        finally:
168
169
            osutils.get_terminal_encoding = default_get_terminal_enc
169
170
 
 
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"])
 
175
        tree.add(["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\"$")
 
179
 
 
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"])
 
184
        tree.add(["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\"$")
 
190
 
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('.')
704
725
        self.assertStartsWith(
705
726
            err, "bzr: ERROR: Could not parse --commit-time:")
706
727
 
 
728
    def test_commit_time_missing_tz(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='2009-10-10 08:00:00' tree/hello.txt", retcode=3)
 
734
        self.assertStartsWith(
 
735
            err, "bzr: ERROR: Could not parse --commit-time:")
 
736
        # Test that it is actually checking and does not simply crash with
 
737
        # some other exception
 
738
        self.assertContainsString(err, "missing a timezone offset")
 
739
 
707
740
    def test_partial_commit_with_renames_in_tree(self):
708
741
        # this test illustrates bug #140419
709
742
        t = self.make_branch_and_tree('.')
821
854
        self.assertEqual(out, '')
822
855
        self.assertContainsRe(err,
823
856
            'Branch.*test_checkout.*appears to be bound to itself')
 
857
 
 
858
    def test_mv_dirs_non_ascii(self):
 
859
        """Move directory with non-ascii name and containing files.
 
860
 
 
861
        Regression test for bug 185211.
 
862
        """
 
863
        tree = self.make_branch_and_tree('.')
 
864
        self.build_tree([u'abc\xc3/', u'abc\xc3/foo'])
 
865
 
 
866
        tree.add([u'abc\xc3/', u'abc\xc3/foo'])
 
867
        tree.commit('checkin')
 
868
 
 
869
        tree.rename_one(u'abc\xc3','abc')
 
870
 
 
871
        self.run_bzr('ci -m "non-ascii mv"')
 
872
 
 
873
 
 
874
class TestSmartServerCommit(TestCaseWithTransport):
 
875
 
 
876
    def test_commit_to_lightweight(self):
 
877
        self.setup_smart_server_with_call_log()
 
878
        t = self.make_branch_and_tree('from')
 
879
        for count in range(9):
 
880
            t.commit(message='commit %d' % count)
 
881
        out, err = self.run_bzr(['checkout', '--lightweight', self.get_url('from'),
 
882
            'target'])
 
883
        self.reset_smart_call_log()
 
884
        self.build_tree(['target/afile'])
 
885
        self.run_bzr(['add', 'target/afile'])
 
886
        out, err = self.run_bzr(['commit', '-m', 'do something', 'target'])
 
887
        # This figure represent the amount of work to perform this use case. It
 
888
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
889
        # being too low. If rpc_count increases, more network roundtrips have
 
890
        # become necessary for this use case. Please do not adjust this number
 
891
        # upwards without agreement from bzr's network support maintainers.
 
892
        self.assertLength(214, self.hpss_calls)
 
893
        self.assertLength(2, self.hpss_connections)
 
894
        self.expectFailure("commit still uses VFS calls",
 
895
            self.assertThat, self.hpss_calls, ContainsNoVfsCalls)