/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: Ian Clatworthy
  • Date: 2008-12-15 06:18:29 UTC
  • mfrom: (3905 +trunk)
  • mto: (3586.1.23 views-ui)
  • mto: This revision was merged to the branch mainline in revision 4030.
  • Revision ID: ian.clatworthy@canonical.com-20081215061829-c8qwa93g71u9fsh5
merge bzr.dev 3905

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import os
21
21
import sys
22
22
 
23
 
import bzrlib
24
23
from bzrlib import (
25
24
    osutils,
26
25
    ignores,
 
26
    msgeditor,
27
27
    osutils,
28
28
    )
29
29
from bzrlib.bzrdir import BzrDir
248
248
        # LANG env variable has no effect on Windows
249
249
        # but some characters anyway cannot be represented
250
250
        # in default user encoding
251
 
        char = probe_bad_non_ascii(bzrlib.user_encoding)
 
251
        char = probe_bad_non_ascii(osutils.get_user_encoding())
252
252
        if char is None:
253
253
            raise TestSkipped('Cannot find suitable non-ascii character'
254
 
                'for user_encoding (%s)' % bzrlib.user_encoding)
 
254
                'for user_encoding (%s)' % osutils.get_user_encoding())
255
255
        out,err = self.run_bzr_subprocess('commit -m "%s"' % char,
256
256
                                          retcode=1,
257
257
                                          env_changes={'LANG': 'C'})
596
596
            retcode=3)
597
597
        self.assertContainsRe(err,
598
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)