~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-12-01 19:41:16 UTC
  • mfrom: (2158 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2159.
  • Revision ID: john@arbash-meinel.com-20061201194116-nvn5qhfxux5284jc
[merge] bzr.dev 2158

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import re
22
22
import sys
23
23
 
 
24
from bzrlib import (
 
25
    ignores,
 
26
    )
24
27
from bzrlib.branch import Branch
25
28
from bzrlib.bzrdir import BzrDir
26
29
from bzrlib.errors import BzrCommandError
35
38
        # If forced, it should succeed, but this is not tested here.
36
39
        self.run_bzr("init")
37
40
        self.build_tree(['hello.txt'])
38
 
        result = self.run_bzr("commit", "-m", "empty", retcode=3)
39
 
        self.assertEqual(('', 'bzr: ERROR: no changes to commit.'
40
 
                              ' use --unchanged to commit anyhow\n'),
41
 
                         result)
 
41
        out,err = self.run_bzr("commit", "-m", "empty", retcode=3)
 
42
        self.assertEqual('', out)
 
43
        self.assertStartsWith(err, 'bzr: ERROR: no changes to commit.'
 
44
                                  ' use --unchanged to commit anyhow\n')
 
45
 
 
46
    def test_commit_success(self):
 
47
        """Successful commit should not leave behind a bzr-commit-* file"""
 
48
        self.run_bzr("init")
 
49
        self.run_bzr("commit", "--unchanged", "-m", "message")
 
50
        self.assertEqual('', self.capture('unknowns'))
 
51
 
 
52
        # same for unicode messages
 
53
        self.run_bzr("commit", "--unchanged", "-m", u'foo\xb5')
 
54
        self.assertEqual('', self.capture('unknowns'))
42
55
 
43
56
    def test_commit_with_path(self):
44
57
        """Commit tree with path of root specified"""
300
313
        self.assertNotContainsRe(result, 'file-a')
301
314
        result = self.run_bzr('status')[0]
302
315
        self.assertContainsRe(result, 'removed:\n  file-a')
 
316
 
 
317
    def test_strict_commit(self):
 
318
        """Commit with --strict works if everything is known"""
 
319
        ignores._set_user_ignores([])
 
320
        tree = self.make_branch_and_tree('tree')
 
321
        self.build_tree(['tree/a'])
 
322
        tree.add('a')
 
323
        # A simple change should just work
 
324
        self.run_bzr('commit', '--strict', '-m', 'adding a',
 
325
                     working_dir='tree')
 
326
 
 
327
    def test_strict_commit_no_changes(self):
 
328
        """commit --strict gives "no changes" if there is nothing to commit"""
 
329
        tree = self.make_branch_and_tree('tree')
 
330
        self.build_tree(['tree/a'])
 
331
        tree.add('a')
 
332
        tree.commit('adding a')
 
333
 
 
334
        # With no changes, it should just be 'no changes'
 
335
        # Make sure that commit is failing because there is nothing to do
 
336
        self.run_bzr_error(['no changes to commit'],
 
337
                           'commit', '--strict', '-m', 'no changes',
 
338
                           working_dir='tree')
 
339
 
 
340
        # But --strict doesn't care if you supply --unchanged
 
341
        self.run_bzr('commit', '--strict', '--unchanged', '-m', 'no changes',
 
342
                     working_dir='tree')
 
343
 
 
344
    def test_strict_commit_unknown(self):
 
345
        """commit --strict fails if a file is unknown"""
 
346
        tree = self.make_branch_and_tree('tree')
 
347
        self.build_tree(['tree/a'])
 
348
        tree.add('a')
 
349
        tree.commit('adding a')
 
350
 
 
351
        # Add one file so there is a change, but forget the other
 
352
        self.build_tree(['tree/b', 'tree/c'])
 
353
        tree.add('b')
 
354
        self.run_bzr_error(['Commit refused because there are unknown files'],
 
355
                           'commit', '--strict', '-m', 'add b',
 
356
                           working_dir='tree')
 
357
 
 
358
        # --no-strict overrides --strict
 
359
        self.run_bzr('commit', '--strict', '-m', 'add b', '--no-strict',
 
360
                     working_dir='tree')