~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2006-04-20 06:37:58 UTC
  • mfrom: (1677 +trunk)
  • mto: (1711.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1678.
  • Revision ID: robertc@robertcollins.net-20060420063758-3cacd9a9925a1a20
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Tests for the commit CLI of bzr."""
19
19
 
20
 
from cStringIO import StringIO
21
20
import os
22
21
import re
23
 
import shutil
24
22
import sys
25
23
 
26
24
from bzrlib.branch import Branch
27
 
import bzrlib.bzrdir as bzrdir
 
25
from bzrlib.bzrdir import BzrDir
28
26
from bzrlib.errors import BzrCommandError
29
27
from bzrlib.tests.blackbox import ExternalBase
30
28
from bzrlib.workingtree import WorkingTree
50
48
                         'Committed revision 1.\n',
51
49
                         err)
52
50
 
53
 
    def test_15_verbose_commit_with_unknown(self):
 
51
    def prepare_simple_history(self):
 
52
        """Prepare and return a working tree with one commit of one file"""
 
53
        # Commit with modified file should say so
 
54
        wt = BzrDir.create_standalone_workingtree('.')
 
55
        self.build_tree(['hello.txt', 'extra.txt'])
 
56
        wt.add(['hello.txt'])
 
57
        wt.commit(message='added')
 
58
        return wt
 
59
 
 
60
    def test_verbose_commit_modified(self):
 
61
        # Verbose commit of modified file should say so
 
62
        wt = self.prepare_simple_history()
 
63
        self.build_tree_contents([('hello.txt', 'new contents')])
 
64
        out, err = self.run_bzr("commit", "-m", "modified")
 
65
        self.assertEqual('', out)
 
66
        self.assertEqual('modified hello.txt\n'
 
67
                         'Committed revision 2.\n',
 
68
                         err)
 
69
 
 
70
    def test_verbose_commit_renamed(self):
 
71
        # Verbose commit of renamed file should say so
 
72
        wt = self.prepare_simple_history()
 
73
        wt.rename_one('hello.txt', 'gutentag.txt')
 
74
        out, err = self.run_bzr("commit", "-m", "renamed")
 
75
        self.assertEqual('', out)
 
76
        self.assertEqual('renamed gutentag.txt\n'
 
77
                         'Committed revision 2.\n',
 
78
                         err)
 
79
 
 
80
    def test_verbose_commit_moved(self):
 
81
        # Verbose commit of file moved to new directory should say so
 
82
        wt = self.prepare_simple_history()
 
83
        os.mkdir('subdir')
 
84
        wt.add(['subdir'])
 
85
        wt.rename_one('hello.txt', 'subdir/hello.txt')
 
86
        out, err = self.run_bzr("commit", "-m", "renamed")
 
87
        self.assertEqual('', out)
 
88
        self.assertEqualDiff('added subdir\n'
 
89
                             'renamed subdir/hello.txt\n'
 
90
                             'Committed revision 2.\n',
 
91
                             err)
 
92
 
 
93
    def test_verbose_commit_with_unknown(self):
54
94
        """Unknown files should not be listed by default in verbose output"""
55
95
        # Is that really the best policy?
56
 
        self.runbzr("init")
 
96
        wt = BzrDir.create_standalone_workingtree('.')
57
97
        self.build_tree(['hello.txt', 'extra.txt'])
58
 
        self.runbzr("add hello.txt")
 
98
        wt.add(['hello.txt'])
59
99
        out,err = self.run_bzr("commit", "-m", "added")
60
100
        self.assertEqual('', out)
61
101
        self.assertEqual('added hello.txt\n'