/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: Robert Collins
  • Date: 2009-03-13 02:25:46 UTC
  • mfrom: (4133 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4183.
  • Revision ID: robertc@robertcollins.net-20090313022546-e7de5zsdkbay5okf
MergeĀ .dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib import (
24
24
    osutils,
25
25
    ignores,
 
26
    msgeditor,
26
27
    osutils,
27
28
    )
28
29
from bzrlib.bzrdir import BzrDir
301
302
    def test_commit_a_text_merge_in_a_checkout(self):
302
303
        # checkouts perform multiple actions in a transaction across bond
303
304
        # branches and their master, and have been observed to fail in the
304
 
        # past. This is a user story reported to fail in bug #43959 where 
 
305
        # past. This is a user story reported to fail in bug #43959 where
305
306
        # a merge done in a checkout (using the update command) failed to
306
307
        # commit correctly.
307
308
        trunk = self.make_branch_and_tree('trunk')
516
517
        self.build_tree(['tree/hello.txt'])
517
518
        tree.add('hello.txt')
518
519
        self.run_bzr_error(
519
 
            ["Invalid bug identifier for %s. Commit refused." % 'lp:orange'],
 
520
            ["Did not understand bug identifier orange: Must be an integer. "
 
521
             "See \"bzr help bugs\" for more information on this feature.\n"
 
522
             "Commit refused."],
520
523
            'commit -m add-b --fixes=lp:orange',
521
524
            working_dir='tree')
522
525
 
526
529
        self.build_tree(['tree/hello.txt'])
527
530
        tree.add('hello.txt')
528
531
        self.run_bzr_error(
529
 
            [r"Invalid bug orange. Must be in the form of 'tag:id'\. "
 
532
            [r"Invalid bug orange. Must be in the form of 'tracker:id'\. "
 
533
             r"See \"bzr help bugs\" for more information on this feature.\n"
530
534
             r"Commit refused\."],
531
535
            'commit -m add-b --fixes=orange',
532
536
            working_dir='tree')
553
557
                     "tree/hello.txt"])
554
558
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
555
559
        properties = last_rev.properties
556
 
        self.assertEqual(u'John D\xf6 <jdoe@example.com>', properties['author'])
 
560
        self.assertEqual(u'John D\xf6 <jdoe@example.com>', properties['authors'])
557
561
 
558
562
    def test_author_no_email(self):
559
563
        """Author's name without an email address is allowed, too."""
564
568
                                "tree/hello.txt")
565
569
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
566
570
        properties = last_rev.properties
567
 
        self.assertEqual('John Doe', properties['author'])
 
571
        self.assertEqual('John Doe', properties['authors'])
 
572
 
 
573
    def test_multiple_authors(self):
 
574
        """Multiple authors can be specyfied, and all are stored."""
 
575
        tree = self.make_branch_and_tree('tree')
 
576
        self.build_tree(['tree/hello.txt'])
 
577
        tree.add('hello.txt')
 
578
        out, err = self.run_bzr("commit -m hello --author='John Doe' "
 
579
                                "--author='Jane Rey' tree/hello.txt")
 
580
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
581
        properties = last_rev.properties
 
582
        self.assertEqual('John Doe\nJane Rey', properties['authors'])
568
583
 
569
584
    def test_partial_commit_with_renames_in_tree(self):
570
585
        # this test illustrates bug #140419
595
610
            retcode=3)
596
611
        self.assertContainsRe(err,
597
612
            r'^bzr: ERROR: Cannot lock.*readonly transport')
 
613
 
 
614
    def test_commit_hook_template(self):
 
615
        # Test that commit template hooks work
 
616
        def restoreDefaults():
 
617
            msgeditor.hooks['commit_message_template'] = []
 
618
            osutils.set_or_unset_env('BZR_EDITOR', default_editor)
 
619
        if sys.platform == "win32":
 
620
            f = file('fed.bat', 'w')
 
621
            f.write('@rem dummy fed')
 
622
            f.close()
 
623
            default_editor = osutils.set_or_unset_env('BZR_EDITOR', "fed.bat")
 
624
        else:
 
625
            f = file('fed.sh', 'wb')
 
626
            f.write('#!/bin/sh\n')
 
627
            f.close()
 
628
            os.chmod('fed.sh', 0755)
 
629
            default_editor = osutils.set_or_unset_env('BZR_EDITOR', "./fed.sh")
 
630
        self.addCleanup(restoreDefaults)
 
631
        msgeditor.hooks.install_named_hook("commit_message_template",
 
632
                lambda commit_obj, msg: "save me some typing\n", None)
 
633
        tree = self.make_branch_and_tree('tree')
 
634
        self.build_tree(['tree/hello.txt'])
 
635
        tree.add('hello.txt')
 
636
        out, err = self.run_bzr("commit tree/hello.txt")
 
637
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
638
        self.assertEqual('save me some typing\n', last_rev.message)