45
38
self.build_tree_contents([('hello.txt', 'my helicopter\n'),
46
39
('nomail.txt', 'nomail\n')])
47
40
wt.add(['hello.txt'])
48
wt.commit('add hello', committer='test@user')
41
self.revision_id_1 = wt.commit('add hello',
42
committer='test@user', timestamp=1165960000.00)
49
43
wt.add(['nomail.txt'])
50
wt.commit('add nomail', committer='no mail')
51
file('hello.txt', 'ab').write('your helicopter')
52
wt.commit('mod hello', committer='user@test')
44
self.revision_id_2 = wt.commit('add nomail',
45
committer='no mail', timestamp=1165970000.00)
46
self.build_tree_contents([('hello.txt', 'my helicopter\n'
47
'your helicopter\n')])
48
self.revision_id_3 = wt.commit('mod hello',
49
committer='user@test', timestamp=1166040000.00)
50
self.build_tree_contents([('hello.txt', 'my helicopter\n'
55
self.revision_id_4 = wt.commit('mod hello',
56
committer='user@test', timestamp=1166050000.00)
54
58
def test_help_annotate(self):
55
59
"""Annotate command exists"""
56
out, err = self.run_bzr_captured(['--no-plugins', 'annotate', '--help'])
60
out, err = self.run_bzr('--no-plugins', 'annotate', '--help')
58
62
def test_annotate_cmd(self):
59
out, err = self.run_bzr_captured(['annotate', 'hello.txt'])
60
self.assertEquals(err, '')
61
self.assertEqualDiff(out, '''\
62
1 test@us | my helicopter
63
3 user@te | your helicopter
63
out, err = self.run_bzr('annotate', 'hello.txt')
64
self.assertEqual('', err)
65
self.assertEqualDiff('''\
66
1 test@us | my helicopter
67
3 user@te | your helicopter
72
def test_annotate_cmd_full(self):
73
out, err = self.run_bzr('annotate', 'hello.txt', '--all')
74
self.assertEqual('', err)
75
self.assertEqualDiff('''\
76
1 test@us | my helicopter
77
3 user@te | your helicopter
79
4 user@te | our helicopters
82
def test_annotate_cmd_long(self):
83
out, err = self.run_bzr('annotate', 'hello.txt', '--long')
84
self.assertEqual('', err)
85
self.assertEqualDiff('''\
86
1 test@user 20061212 | my helicopter
87
3 user@test 20061213 | your helicopter
88
4 user@test 20061213 | all of
92
def test_annotate_cmd_show_ids(self):
93
out, err = self.run_bzr('annotate', 'hello.txt', '--show-ids')
94
max_len = max([len(self.revision_id_1),
95
len(self.revision_id_3),
96
len(self.revision_id_4)])
97
self.assertEqual('', err)
98
self.assertEqualDiff('''\
100
%*s | your helicopter
102
%*s | our helicopters
103
''' % (max_len, self.revision_id_1,
104
max_len, self.revision_id_3,
105
max_len, self.revision_id_4,
66
110
def test_no_mail(self):
67
out, err = self.run_bzr_captured(['annotate', 'nomail.txt'])
68
self.assertEquals(err, '')
69
self.assertEqualDiff(out, '''\
111
out, err = self.run_bzr('annotate', 'nomail.txt')
112
self.assertEqual('', err)
113
self.assertEqualDiff('''\
73
117
def test_annotate_cmd_revision(self):
74
out, err = self.run_bzr_captured(['annotate', 'hello.txt', '-r1'])
75
self.assertEquals(err, '')
76
self.assertEqualDiff(out, '''\
77
1 test@us | my helicopter
118
out, err = self.run_bzr('annotate', 'hello.txt', '-r1')
119
self.assertEqual('', err)
120
self.assertEqualDiff('''\
121
1 test@us | my helicopter
80
124
def test_annotate_cmd_revision3(self):
81
out, err = self.run_bzr_captured(['annotate', 'hello.txt', '-r3'])
82
self.assertEquals(err, '')
83
self.assertEqualDiff(out, '''\
84
1 test@us | my helicopter
85
3 user@te | your helicopter
125
out, err = self.run_bzr('annotate', 'hello.txt', '-r3')
126
self.assertEqual('', err)
127
self.assertEqualDiff('''\
128
1 test@us | my helicopter
129
3 user@te | your helicopter
88
132
def test_annotate_cmd_unknown_revision(self):
89
out, err = self.run_bzr_captured(['annotate', 'hello.txt', '-r', '10'],
91
self.assertEquals(out, '')
133
out, err = self.run_bzr('annotate', 'hello.txt', '-r', '10',
135
self.assertEqual('', out)
92
136
self.assertContainsRe(err, 'Requested revision: \'10\' does not exist')
94
138
def test_annotate_cmd_two_revisions(self):
95
out, err = self.run_bzr_captured(['annotate', 'hello.txt', '-r1..2'],
97
self.assertEquals(out, '')
98
self.assertEquals(err, 'bzr: ERROR: bzr annotate --revision takes'
99
' exactly 1 argument\n')
139
out, err = self.run_bzr('annotate', 'hello.txt', '-r1..2',
141
self.assertEqual('', out)
142
self.assertEqual('bzr: ERROR: bzr annotate --revision takes'
143
' exactly 1 argument\n',
101
146
def test_annotate_empty_file(self):
102
147
tree = self.make_branch_and_tree('tree')