~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-11-30 22:04:45 UTC
  • mfrom: (4789.28.4 2.1.0b4-builder-no-keys)
  • Revision ID: pqm@pqm.ubuntu.com-20091130220445-vbfmmgocbgcs195q
(jam) Update BTreeBuilder to remove ._keys and use StaticTuple

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    ignores,
26
26
    msgeditor,
27
27
    osutils,
 
28
    tests,
28
29
    )
29
30
from bzrlib.bzrdir import BzrDir
30
31
from bzrlib.tests import (
170
171
        self.assertEqual(err, 'Committing to: %s\n'
171
172
                         'Committed revision 2.\n' % expected)
172
173
 
 
174
    def test_commit_sanitizes_CR_in_message(self):
 
175
        # See bug #433779, basically Emacs likes to pass '\r\n' style line
 
176
        # endings to 'bzr commit -m ""' which breaks because we don't allow
 
177
        # '\r' in commit messages. (Mostly because of issues where XML style
 
178
        # formats arbitrarily strip it out of the data while parsing.)
 
179
        # To make life easier for users, we just always translate '\r\n' =>
 
180
        # '\n'. And '\r' => '\n'.
 
181
        a_tree = self.make_branch_and_tree('a')
 
182
        self.build_tree(['a/b'])
 
183
        a_tree.add('b')
 
184
        self.run_bzr(['commit',
 
185
                      '-m', 'a string\r\n\r\nwith mixed\r\rendings\n'],
 
186
                     working_dir='a')
 
187
        rev_id = a_tree.branch.last_revision()
 
188
        rev = a_tree.branch.repository.get_revision(rev_id)
 
189
        self.assertEqualDiff('a string\n\nwith mixed\n\nendings\n',
 
190
                             rev.message)
 
191
 
173
192
    def test_commit_merge_reports_all_modified_files(self):
174
193
        # the commit command should show all the files that are shown by
175
194
        # bzr diff or bzr status when committing, even when they were not
245
264
        self.run_bzr('commit -m ""', retcode=3)
246
265
 
247
266
    def test_unsupported_encoding_commit_message(self):
 
267
        if sys.platform == 'win32':
 
268
            raise tests.TestNotApplicable('Win32 parses arguments directly'
 
269
                ' as Unicode, so we can\'t pass invalid non-ascii')
248
270
        tree = self.make_branch_and_tree('.')
249
271
        self.build_tree_contents([('foo.c', 'int main() {}')])
250
272
        tree.add('foo.c')
255
277
        if char is None:
256
278
            raise TestSkipped('Cannot find suitable non-ascii character'
257
279
                'for user_encoding (%s)' % osutils.get_user_encoding())
258
 
        # TODO: jam 2009-07-23 This test seems to fail on Windows now. My best
259
 
        #       guess is that the change to use Unicode command lines means
260
 
        #       that we no longer pay any attention to LANG=C when decoding the
261
 
        #       commandline arguments.
262
280
        out,err = self.run_bzr_subprocess('commit -m "%s"' % char,
263
281
                                          retcode=1,
264
282
                                          env_changes={'LANG': 'C'})
590
608
        properties = last_rev.properties
591
609
        self.assertEqual('John Doe\nJane Rey', properties['authors'])
592
610
 
 
611
    def test_commit_time(self):
 
612
        tree = self.make_branch_and_tree('tree')
 
613
        self.build_tree(['tree/hello.txt'])
 
614
        tree.add('hello.txt')
 
615
        out, err = self.run_bzr("commit -m hello "
 
616
            "--commit-time='2009-10-10 08:00:00 +0100' tree/hello.txt")
 
617
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
618
        self.assertEqual(
 
619
            'Sat 2009-10-10 08:00:00 +0100',
 
620
            osutils.format_date(last_rev.timestamp, last_rev.timezone))
 
621
        
 
622
    def test_commit_time_bad_time(self):
 
623
        tree = self.make_branch_and_tree('tree')
 
624
        self.build_tree(['tree/hello.txt'])
 
625
        tree.add('hello.txt')
 
626
        out, err = self.run_bzr("commit -m hello "
 
627
            "--commit-time='NOT A TIME' tree/hello.txt", retcode=3)
 
628
        self.assertStartsWith(
 
629
            err, "bzr: ERROR: Could not parse --commit-time:")
 
630
 
593
631
    def test_partial_commit_with_renames_in_tree(self):
594
632
        # this test illustrates bug #140419
595
633
        t = self.make_branch_and_tree('.')