34
31
class TestCommit(ExternalBase):
36
def test_empty_commit(self):
33
def test_05_empty_commit(self):
34
"""Commit of tree with no versioned files should fail"""
35
# If forced, it should succeed, but this is not tested here.
37
36
self.runbzr("init")
38
37
self.build_tree(['hello.txt'])
39
38
self.runbzr("commit -m empty", retcode=3)
40
self.runbzr("add hello.txt")
41
self.runbzr("commit -m added")
40
def test_10_verbose_commit(self):
41
"""Add one file and examine verbose commit output"""
43
self.build_tree(['hello.txt'])
44
self.runbzr("add hello.txt")
45
out,err = self.run_bzr("commit", "-m", "added")
46
self.assertEqual('', out)
47
self.assertEqual('added hello.txt\n'
48
'Committed revision 1.\n',
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'])
57
wt.commit(message='added')
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',
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',
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()
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',
93
def test_verbose_commit_with_unknown(self):
94
"""Unknown files should not be listed by default in verbose output"""
95
# Is that really the best policy?
96
wt = BzrDir.create_standalone_workingtree('.')
97
self.build_tree(['hello.txt', 'extra.txt'])
99
out,err = self.run_bzr("commit", "-m", "added")
100
self.assertEqual('', out)
101
self.assertEqual('added hello.txt\n'
102
'Committed revision 1.\n',
105
def test_16_verbose_commit_with_unchanged(self):
106
"""Unchanged files should not be listed by default in verbose output"""
108
self.build_tree(['hello.txt', 'unchanged.txt'])
109
self.runbzr('add unchanged.txt')
110
self.runbzr('commit -m unchanged unchanged.txt')
111
self.runbzr("add hello.txt")
112
out,err = self.run_bzr("commit", "-m", "added")
113
self.assertEqual('', out)
114
self.assertEqual('added hello.txt\n'
115
'Committed revision 2.\n',
43
118
def test_empty_commit_message(self):
44
119
self.runbzr("init")
45
120
file('foo.c', 'wt').write('int main() {}')
46
121
self.runbzr(['add', 'foo.c'])
47
self.runbzr(["commit", "-m", ""] , retcode=3)
122
self.runbzr(["commit", "-m", ""] , retcode=3)
49
124
def test_other_branch_commit(self):
50
125
# this branch is to ensure consistent behaviour, whether we're run