~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2006-11-21 08:19:35 UTC
  • mfrom: (2018.8.1 split smart)
  • mto: (2018.5.35 hpss)
  • mto: This revision was merged to the branch mainline in revision 2435.
  • Revision ID: andrew.bennetts@canonical.com-20061121081935-6440ef860ef00262
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        # If forced, it should succeed, but this is not tested here.
36
36
        self.run_bzr("init")
37
37
        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)
 
38
        out,err = self.run_bzr("commit", "-m", "empty", retcode=3)
 
39
        self.assertEqual('', out)
 
40
        self.assertStartsWith(err, 'bzr: ERROR: no changes to commit.'
 
41
                                  ' use --unchanged to commit anyhow\n')
 
42
 
 
43
    def test_save_commit_message(self):
 
44
        """Failed commit should save the message in a file"""
 
45
        self.run_bzr("init")
 
46
        out,err = self.run_bzr("commit", "-m", "message", retcode=3)
 
47
        self.assertEqual('', out)
 
48
        self.assertStartsWith(err, 'bzr: ERROR: no changes to commit.'
 
49
                                  ' use --unchanged to commit anyhow\n'
 
50
                                  'Commit message saved. To reuse the message,'
 
51
                                  ' do\nbzr commit --file ')
 
52
        message_file = re.compile('bzr-commit-\S*').search(err).group()
 
53
        self.check_file_contents(message_file, 'message')
 
54
 
 
55
    def test_commit_success(self):
 
56
        """Successful commit should not leave behind a bzr-commit-* file"""
 
57
        self.run_bzr("init")
 
58
        self.run_bzr("commit", "--unchanged", "-m", "message")
 
59
        self.assertEqual('', self.capture('unknowns'))
 
60
 
 
61
        # same for unicode messages
 
62
        self.run_bzr("commit", "--unchanged", "-m", u'foo\xb5')
 
63
        self.assertEqual('', self.capture('unknowns'))
42
64
 
43
65
    def test_commit_with_path(self):
44
66
        """Commit tree with path of root specified"""
300
322
        self.assertNotContainsRe(result, 'file-a')
301
323
        result = self.run_bzr('status')[0]
302
324
        self.assertContainsRe(result, 'removed:\n  file-a')
 
325
 
 
326
    def test_strict_commit(self):
 
327
        """Commit with --strict works if everything is known"""
 
328
        tree = self.make_branch_and_tree('tree')
 
329
        self.build_tree(['tree/a'])
 
330
        tree.add('a')
 
331
        # A simple change should just work
 
332
        self.run_bzr('commit', '--strict', '-m', 'adding a',
 
333
                     working_dir='tree')
 
334
 
 
335
    def test_strict_commit_no_changes(self):
 
336
        """commit --strict gives "no changes" if there is nothing to commit"""
 
337
        tree = self.make_branch_and_tree('tree')
 
338
        self.build_tree(['tree/a'])
 
339
        tree.add('a')
 
340
        tree.commit('adding a')
 
341
 
 
342
        # With no changes, it should just be 'no changes'
 
343
        # Make sure that commit is failing because there is nothing to do
 
344
        self.run_bzr_error(['no changes to commit'],
 
345
                           'commit', '--strict', '-m', 'no changes',
 
346
                           working_dir='tree')
 
347
 
 
348
        # But --strict doesn't care if you supply --unchanged
 
349
        self.run_bzr('commit', '--strict', '--unchanged', '-m', 'no changes',
 
350
                     working_dir='tree')
 
351
 
 
352
    def test_strict_commit_unknown(self):
 
353
        """commit --strict fails if a file is unknown"""
 
354
        tree = self.make_branch_and_tree('tree')
 
355
        self.build_tree(['tree/a'])
 
356
        tree.add('a')
 
357
        tree.commit('adding a')
 
358
 
 
359
        # Add one file so there is a change, but forget the other
 
360
        self.build_tree(['tree/b', 'tree/c'])
 
361
        tree.add('b')
 
362
        self.run_bzr_error(['Commit refused because there are unknown files'],
 
363
                           'commit', '--strict', '-m', 'add b',
 
364
                           working_dir='tree')
 
365
 
 
366
        # --no-strict overrides --strict
 
367
        self.run_bzr('commit', '--strict', '-m', 'add b', '--no-strict',
 
368
                     working_dir='tree')