/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: John Arbash Meinel
  • Date: 2008-12-16 14:58:29 UTC
  • mfrom: (3903 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3913.
  • Revision ID: john@arbash-meinel.com-20081216145829-fqis79ouytgbcj4t
Merge in bzr.dev, pull out some of the retry on copy_revision_texts code.

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
595
596
            retcode=3)
596
597
        self.assertContainsRe(err,
597
598
            r'^bzr: ERROR: Cannot lock.*readonly transport')
 
599
 
 
600
    def test_commit_hook_template(self):
 
601
        # Test that commit template hooks work
 
602
        def restoreDefaults():
 
603
            msgeditor.hooks['commit_message_template'] = []
 
604
            osutils.set_or_unset_env('BZR_EDITOR', default_editor)
 
605
        if sys.platform == "win32":
 
606
            f = file('fed.bat', 'w')
 
607
            f.write('@rem dummy fed')
 
608
            f.close()
 
609
            default_editor = osutils.set_or_unset_env('BZR_EDITOR', "fed.bat")
 
610
        else:
 
611
            f = file('fed.sh', 'wb')
 
612
            f.write('#!/bin/sh\n')
 
613
            f.close()
 
614
            os.chmod('fed.sh', 0755)
 
615
            default_editor = osutils.set_or_unset_env('BZR_EDITOR', "./fed.sh")
 
616
        self.addCleanup(restoreDefaults)
 
617
        msgeditor.hooks.install_named_hook("commit_message_template",
 
618
                lambda commit_obj, msg: "save me some typing\n", None)
 
619
        tree = self.make_branch_and_tree('tree')
 
620
        self.build_tree(['tree/hello.txt'])
 
621
        tree.add('hello.txt')
 
622
        out, err = self.run_bzr("commit tree/hello.txt")
 
623
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
624
        self.assertEqual('save me some typing\n', last_rev.message)