/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2011-11-24 15:48:29 UTC
  • mfrom: (6289 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6337.
  • Revision ID: v.ladeuil+lp@free.fr-20111124154829-avowjpsxdl8yp2vz
merge trunk resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    osutils,
30
30
    ignores,
31
31
    msgeditor,
32
 
    tests,
33
32
    )
34
33
from bzrlib.bzrdir import BzrDir
35
34
from bzrlib.tests import (
36
 
    probe_bad_non_ascii,
37
35
    test_foreign,
38
 
    TestSkipped,
39
 
    UnicodeFilenameFeature,
 
36
    features,
40
37
    )
41
38
from bzrlib.tests import TestCaseWithTransport
42
39
 
138
135
    def test_unicode_commit_message_is_filename(self):
139
136
        """Unicode commit message same as a filename (Bug #563646).
140
137
        """
141
 
        self.requireFeature(UnicodeFilenameFeature)
 
138
        self.requireFeature(features.UnicodeFilenameFeature)
142
139
        file_name = u'\N{euro sign}'
143
140
        self.run_bzr(['init'])
144
141
        open(file_name, 'w').write('hello world')
332
329
        tree = self.make_branch_and_tree('.')
333
330
        self.build_tree_contents([('foo.c', 'int main() {}')])
334
331
        tree.add('foo.c')
335
 
        self.run_bzr('commit -m ""', retcode=3)
 
332
        self.run_bzr('commit -m ""')
336
333
 
337
334
    def test_other_branch_commit(self):
338
335
        # this branch is to ensure consistent behaviour, whether we're run
599
596
            'commit -m add-b --fixes=xxx:123',
600
597
            working_dir='tree')
601
598
 
 
599
    def test_fixes_bug_with_default_tracker(self):
 
600
        """commit --fixes=234 uses the default bug tracker."""
 
601
        tree = self.make_branch_and_tree('tree')
 
602
        self.build_tree(['tree/hello.txt'])
 
603
        tree.add('hello.txt')
 
604
        self.run_bzr_error(
 
605
            ["bzr: ERROR: No tracker specified for bug 123. Use the form "
 
606
            "'tracker:id' or specify a default bug tracker using the "
 
607
            "`bugtracker` option.\n"
 
608
            "See \"bzr help bugs\" for more information on this feature. "
 
609
            "Commit refused."],
 
610
            'commit -m add-b --fixes=123',
 
611
            working_dir='tree')
 
612
        tree.branch.get_config().set_user_option("bugtracker", "lp")
 
613
        self.run_bzr('commit -m hello --fixes=234 tree/hello.txt')
 
614
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
615
        self.assertEqual('https://launchpad.net/bugs/234 fixed',
 
616
                         last_rev.properties['bugs'])
 
617
 
602
618
    def test_fixes_invalid_bug_number(self):
603
619
        tree = self.make_branch_and_tree('tree')
604
620
        self.build_tree(['tree/hello.txt'])
616
632
        self.build_tree(['tree/hello.txt'])
617
633
        tree.add('hello.txt')
618
634
        self.run_bzr_error(
619
 
            [r"Invalid bug orange. Must be in the form of 'tracker:id'\. "
620
 
             r"See \"bzr help bugs\" for more information on this feature.\n"
621
 
             r"Commit refused\."],
622
 
            'commit -m add-b --fixes=orange',
 
635
            [r"Invalid bug orange:apples:bananas. Must be in the form of "
 
636
             r"'tracker:id'\. See \"bzr help bugs\" for more information on "
 
637
             r"this feature.\nCommit refused\."],
 
638
            'commit -m add-b --fixes=orange:apples:bananas',
623
639
            working_dir='tree')
624
640
 
625
641
    def test_no_author(self):
688
704
        self.assertStartsWith(
689
705
            err, "bzr: ERROR: Could not parse --commit-time:")
690
706
 
 
707
    def test_commit_time_missing_tz(self):
 
708
        tree = self.make_branch_and_tree('tree')
 
709
        self.build_tree(['tree/hello.txt'])
 
710
        tree.add('hello.txt')
 
711
        out, err = self.run_bzr("commit -m hello "
 
712
            "--commit-time='2009-10-10 08:00:00' tree/hello.txt", retcode=3)
 
713
        self.assertStartsWith(
 
714
            err, "bzr: ERROR: Could not parse --commit-time:")
 
715
        # Test that it is actually checking and does not simply crash with
 
716
        # some other exception
 
717
        self.assertContainsString(err, "missing a timezone offset")
 
718
 
691
719
    def test_partial_commit_with_renames_in_tree(self):
692
720
        # this test illustrates bug #140419
693
721
        t = self.make_branch_and_tree('.')
741
769
        tree.add('hello.txt')
742
770
        return tree
743
771
 
 
772
    def test_edit_empty_message(self):
 
773
        tree = self.make_branch_and_tree('tree')
 
774
        self.setup_editor()
 
775
        self.build_tree(['tree/hello.txt'])
 
776
        tree.add('hello.txt')
 
777
        out, err = self.run_bzr("commit tree/hello.txt", retcode=3,
 
778
            stdin="y\n")
 
779
        self.assertContainsRe(err,
 
780
            "bzr: ERROR: Empty commit message specified")
 
781
 
744
782
    def test_commit_hook_template_accepted(self):
745
783
        tree = self.setup_commit_with_template()
746
784
        out, err = self.run_bzr("commit tree/hello.txt", stdin="y\n")
750
788
    def test_commit_hook_template_rejected(self):
751
789
        tree = self.setup_commit_with_template()
752
790
        expected = tree.last_revision()
753
 
        out, err = self.run_bzr_error(["empty commit message"],
 
791
        out, err = self.run_bzr_error(["Empty commit message specified."
 
792
                  " Please specify a commit message with either"
 
793
                  " --message or --file or leave a blank message"
 
794
                  " with --message \"\"."],
754
795
            "commit tree/hello.txt", stdin="n\n")
755
796
        self.assertEqual(expected, tree.last_revision())
756
797