~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Abbreviate pack_stat struct format to '>6L'

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
 
57
54
            err,
58
55
            DocTestMatches("""\
59
56
Committing to: ...
60
 
aborting commit write group: PointlessCommit(No changes to commit)
61
57
bzr: ERROR: No changes to commit.\
62
58
 Please 'bzr add' the files you want to commit,\
63
59
 or use --unchanged to force an empty commit.
139
135
    def test_unicode_commit_message_is_filename(self):
140
136
        """Unicode commit message same as a filename (Bug #563646).
141
137
        """
142
 
        self.requireFeature(UnicodeFilenameFeature)
 
138
        self.requireFeature(features.UnicodeFilenameFeature)
143
139
        file_name = u'\N{euro sign}'
144
140
        self.run_bzr(['init'])
145
141
        open(file_name, 'w').write('hello world')
333
329
        tree = self.make_branch_and_tree('.')
334
330
        self.build_tree_contents([('foo.c', 'int main() {}')])
335
331
        tree.add('foo.c')
336
 
        self.run_bzr('commit -m ""', retcode=3)
 
332
        self.run_bzr('commit -m ""')
337
333
 
338
334
    def test_other_branch_commit(self):
339
335
        # this branch is to ensure consistent behaviour, whether we're run
600
596
            'commit -m add-b --fixes=xxx:123',
601
597
            working_dir='tree')
602
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
 
603
618
    def test_fixes_invalid_bug_number(self):
604
619
        tree = self.make_branch_and_tree('tree')
605
620
        self.build_tree(['tree/hello.txt'])
617
632
        self.build_tree(['tree/hello.txt'])
618
633
        tree.add('hello.txt')
619
634
        self.run_bzr_error(
620
 
            [r"Invalid bug orange. Must be in the form of 'tracker:id'\. "
621
 
             r"See \"bzr help bugs\" for more information on this feature.\n"
622
 
             r"Commit refused\."],
623
 
            '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',
624
639
            working_dir='tree')
625
640
 
626
641
    def test_no_author(self):
742
757
        tree.add('hello.txt')
743
758
        return tree
744
759
 
 
760
    def test_edit_empty_message(self):
 
761
        tree = self.make_branch_and_tree('tree')
 
762
        self.setup_editor()
 
763
        self.build_tree(['tree/hello.txt'])
 
764
        tree.add('hello.txt')
 
765
        out, err = self.run_bzr("commit tree/hello.txt", retcode=3,
 
766
            stdin="y\n")
 
767
        self.assertContainsRe(err,
 
768
            "bzr: ERROR: Empty commit message specified")
 
769
 
745
770
    def test_commit_hook_template_accepted(self):
746
771
        tree = self.setup_commit_with_template()
747
772
        out, err = self.run_bzr("commit tree/hello.txt", stdin="y\n")
751
776
    def test_commit_hook_template_rejected(self):
752
777
        tree = self.setup_commit_with_template()
753
778
        expected = tree.last_revision()
754
 
        out, err = self.run_bzr_error(["empty commit message"],
 
779
        out, err = self.run_bzr_error(["Empty commit message specified."
 
780
                  " Please specify a commit message with either"
 
781
                  " --message or --file or leave a blank message"
 
782
                  " with --message \"\"."],
755
783
            "commit tree/hello.txt", stdin="n\n")
756
784
        self.assertEqual(expected, tree.last_revision())
757
785
 
 
786
    def test_set_commit_message(self):
 
787
        msgeditor.hooks.install_named_hook("set_commit_message",
 
788
                lambda commit_obj, msg: "save me some typing\n", None)
 
789
        tree = self.make_branch_and_tree('tree')
 
790
        self.build_tree(['tree/hello.txt'])
 
791
        tree.add('hello.txt')
 
792
        out, err = self.run_bzr("commit tree/hello.txt")
 
793
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
794
        self.assertEqual('save me some typing\n', last_rev.message)
 
795
 
758
796
    def test_commit_without_username(self):
759
797
        """Ensure commit error if username is not set.
760
798
        """
783
821
        self.assertEqual(out, '')
784
822
        self.assertContainsRe(err,
785
823
            'Branch.*test_checkout.*appears to be bound to itself')
786