~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Packman
  • Date: 2012-01-05 09:50:04 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6426.
  • Revision ID: martin.packman@canonical.com-20120105095004-mia9xb7y0efmto0v
Merge bzr.dev to resolve conflicts in bzrlib.builtins

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('.')
596
617
            'commit -m add-b --fixes=xxx:123',
597
618
            working_dir='tree')
598
619
 
 
620
    def test_fixes_bug_with_default_tracker(self):
 
621
        """commit --fixes=234 uses the default bug tracker."""
 
622
        tree = self.make_branch_and_tree('tree')
 
623
        self.build_tree(['tree/hello.txt'])
 
624
        tree.add('hello.txt')
 
625
        self.run_bzr_error(
 
626
            ["bzr: ERROR: No tracker specified for bug 123. Use the form "
 
627
            "'tracker:id' or specify a default bug tracker using the "
 
628
            "`bugtracker` option.\n"
 
629
            "See \"bzr help bugs\" for more information on this feature. "
 
630
            "Commit refused."],
 
631
            'commit -m add-b --fixes=123',
 
632
            working_dir='tree')
 
633
        tree.branch.get_config().set_user_option("bugtracker", "lp")
 
634
        self.run_bzr('commit -m hello --fixes=234 tree/hello.txt')
 
635
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
636
        self.assertEqual('https://launchpad.net/bugs/234 fixed',
 
637
                         last_rev.properties['bugs'])
 
638
 
599
639
    def test_fixes_invalid_bug_number(self):
600
640
        tree = self.make_branch_and_tree('tree')
601
641
        self.build_tree(['tree/hello.txt'])
613
653
        self.build_tree(['tree/hello.txt'])
614
654
        tree.add('hello.txt')
615
655
        self.run_bzr_error(
616
 
            [r"Invalid bug orange. Must be in the form of 'tracker:id'\. "
617
 
             r"See \"bzr help bugs\" for more information on this feature.\n"
618
 
             r"Commit refused\."],
619
 
            'commit -m add-b --fixes=orange',
 
656
            [r"Invalid bug orange:apples:bananas. Must be in the form of "
 
657
             r"'tracker:id'\. See \"bzr help bugs\" for more information on "
 
658
             r"this feature.\nCommit refused\."],
 
659
            'commit -m add-b --fixes=orange:apples:bananas',
620
660
            working_dir='tree')
621
661
 
622
662
    def test_no_author(self):
685
725
        self.assertStartsWith(
686
726
            err, "bzr: ERROR: Could not parse --commit-time:")
687
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
 
688
740
    def test_partial_commit_with_renames_in_tree(self):
689
741
        # this test illustrates bug #140419
690
742
        t = self.make_branch_and_tree('.')
802
854
        self.assertEqual(out, '')
803
855
        self.assertContainsRe(err,
804
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)