~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin
  • Date: 2011-03-22 00:33:21 UTC
  • mto: This revision was merged to the branch mainline in revision 5731.
  • Revision ID: gzlist@googlemail.com-20110322003321-h3n4q806g759tk7v
Tweak function descriptions in delta header for clarity

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
22
22
import sys
23
23
 
24
24
from bzrlib import (
 
25
    bzrdir,
25
26
    osutils,
26
27
    ignores,
27
28
    msgeditor,
32
33
from bzrlib.tests import (
33
34
    probe_bad_non_ascii,
34
35
    TestSkipped,
 
36
    UnicodeFilenameFeature,
35
37
    )
36
 
from bzrlib.tests.blackbox import ExternalBase
37
 
 
38
 
 
39
 
class TestCommit(ExternalBase):
 
38
from bzrlib.tests import TestCaseWithTransport
 
39
 
 
40
 
 
41
class TestCommit(TestCaseWithTransport):
40
42
 
41
43
    def test_05_empty_commit(self):
42
44
        """Commit of tree with no versioned files should fail"""
111
113
    def test_unicode_commit_message_is_filename(self):
112
114
        """Unicode commit message same as a filename (Bug #563646).
113
115
        """
 
116
        self.requireFeature(UnicodeFilenameFeature)
114
117
        file_name = u'\N{euro sign}'
115
118
        self.run_bzr(['init'])
116
119
        open(file_name, 'w').write('hello world')
129
132
        # by ui.text.show_warning
130
133
        default_get_terminal_enc = osutils.get_terminal_encoding
131
134
        try:
132
 
            osutils.get_terminal_encoding = lambda: 'ascii'
 
135
            osutils.get_terminal_encoding = lambda trace=None: 'ascii'
133
136
            file_name = u'foo\u1234'
134
137
            open(file_name, 'w').write('hello world')
135
138
            self.run_bzr(['add'])
698
701
        self.assertContainsRe(err, r'modified test\nCommitted revision 2.')
699
702
 
700
703
    def test_commit_readonly_checkout(self):
701
 
        # https://bugs.edge.launchpad.net/bzr/+bug/129701
 
704
        # https://bugs.launchpad.net/bzr/+bug/129701
702
705
        # "UnlockableTransport error trying to commit in checkout of readonly
703
706
        # branch"
704
707
        self.make_branch('master')
716
719
            f = file('fed.bat', 'w')
717
720
            f.write('@rem dummy fed')
718
721
            f.close()
719
 
            osutils.set_or_unset_env('BZR_EDITOR', "fed.bat")
 
722
            self.overrideEnv('BZR_EDITOR', "fed.bat")
720
723
        else:
721
724
            f = file('fed.sh', 'wb')
722
725
            f.write('#!/bin/sh\n')
723
726
            f.close()
724
727
            os.chmod('fed.sh', 0755)
725
 
            osutils.set_or_unset_env('BZR_EDITOR', "./fed.sh")
 
728
            self.overrideEnv('BZR_EDITOR', "./fed.sh")
726
729
 
727
730
    def setup_commit_with_template(self):
728
731
        self.setup_editor()
753
756
        os.chdir('foo')
754
757
        open('foo.txt', 'w').write('hello')
755
758
        self.run_bzr(['add'])
756
 
        osutils.set_or_unset_env('EMAIL', None)
757
 
        osutils.set_or_unset_env('BZR_EMAIL', None)
 
759
        self.overrideEnv('EMAIL', None)
 
760
        self.overrideEnv('BZR_EMAIL', None)
758
761
        out, err = self.run_bzr(['commit', '-m', 'initial'], 3)
759
762
        self.assertContainsRe(err, 'Unable to determine your name')
 
763
 
 
764
    def test_commit_recursive_checkout(self):
 
765
        """Ensure that a commit to a recursive checkout fails cleanly.
 
766
        """
 
767
        self.run_bzr(['init', 'test_branch'])
 
768
        self.run_bzr(['checkout', 'test_branch', 'test_checkout'])
 
769
        os.chdir('test_checkout')
 
770
        self.run_bzr(['bind', '.']) # bind to self
 
771
        open('foo.txt', 'w').write('hello')
 
772
        self.run_bzr(['add'])
 
773
        out, err = self.run_bzr(['commit', '-m', 'addedfoo'], 3)
 
774
        self.assertEqual(out, '')
 
775
        self.assertContainsRe(err,
 
776
            'Branch.*test_checkout.*appears to be bound to itself')
 
777