62
64
def test_help_annotate(self):
63
65
"""Annotate command exists"""
64
out, err = self.run_bzr('--no-plugins', 'annotate', '--help')
66
out, err = self.run_bzr('--no-plugins annotate --help')
66
68
def test_annotate_cmd(self):
67
out, err = self.run_bzr('annotate', 'hello.txt')
69
out, err = self.run_bzr('annotate hello.txt')
68
70
self.assertEqual('', err)
69
71
self.assertEqualDiff('''\
70
72
1 test@us | my helicopter
114
116
def test_no_mail(self):
115
out, err = self.run_bzr('annotate', 'nomail.txt')
117
out, err = self.run_bzr('annotate nomail.txt')
116
118
self.assertEqual('', err)
117
119
self.assertEqualDiff('''\
118
120
2 no mail | nomail
121
123
def test_annotate_cmd_revision(self):
122
out, err = self.run_bzr('annotate', 'hello.txt', '-r1')
124
out, err = self.run_bzr('annotate hello.txt -r1')
123
125
self.assertEqual('', err)
124
126
self.assertEqualDiff('''\
125
127
1 test@us | my helicopter
128
130
def test_annotate_cmd_revision3(self):
129
out, err = self.run_bzr('annotate', 'hello.txt', '-r3')
131
out, err = self.run_bzr('annotate hello.txt -r3')
130
132
self.assertEqual('', err)
131
133
self.assertEqualDiff('''\
132
134
1 test@us | my helicopter
136
138
def test_annotate_cmd_unknown_revision(self):
137
out, err = self.run_bzr('annotate', 'hello.txt', '-r', '10',
139
out, err = self.run_bzr('annotate hello.txt -r 10',
139
141
self.assertEqual('', out)
140
142
self.assertContainsRe(err, 'Requested revision: \'10\' does not exist')
142
144
def test_annotate_cmd_two_revisions(self):
143
out, err = self.run_bzr('annotate', 'hello.txt', '-r1..2',
145
out, err = self.run_bzr('annotate hello.txt -r1..2',
145
147
self.assertEqual('', out)
146
148
self.assertEqual('bzr: ERROR: bzr annotate --revision takes'
147
' exactly 1 argument\n',
149
' exactly one revision identifier\n',
153
class TestSimpleAnnotate(TestCaseWithTransport):
154
"""Annotate tests with no complex setup."""
156
def _setup_edited_file(self):
157
"""Create a tree with a locally edited file."""
158
tree = self.make_branch_and_tree('.')
159
self.build_tree_contents([('file', 'foo\ngam\n')])
161
tree.commit('add file', committer="test@host", rev_id="rev1")
162
self.build_tree_contents([('file', 'foo\nbar\ngam\n')])
163
tree.branch.get_config().set_user_option('email', 'current@host2')
165
def test_annotate_edited_file(self):
166
tree = self._setup_edited_file()
167
out, err = self.run_bzr('annotate file')
174
def test_annotate_edited_file_show_ids(self):
175
tree = self._setup_edited_file()
176
out, err = self.run_bzr('annotate file --show-ids')
183
def _create_merged_file(self):
184
"""Create a file with a pending merge and local edit."""
185
tree = self.make_branch_and_tree('.')
186
self.build_tree_contents([('file', 'foo\ngam\n')])
188
tree.commit('add file', rev_id="rev1", committer="test@host")
190
self.build_tree_contents([('file', 'foo\nbar\ngam\n')])
191
tree.commit("right", rev_id="rev1.1.1", committer="test@host")
192
tree.pull(tree.branch, True, "rev1")
194
self.build_tree_contents([('file', 'foo\nbaz\ngam\n')])
195
tree.commit("left", rev_id="rev2", committer="test@host")
197
tree.merge_from_branch(tree.branch, "rev1.1.1")
198
# edit the file to be 'resolved' and have a further local edit
199
self.build_tree_contents([('file', 'local\nfoo\nbar\nbaz\ngam\n')])
201
def test_annotated_edited_merged_file_revnos(self):
202
self._create_merged_file()
203
out, err = self.run_bzr('annotate file')
204
email = extract_email_address(Branch.open('.').get_config().username())
208
'1.1.1 test@ho | bar\n'
210
'1 test@ho | gam\n' % email[:7],
213
def test_annotated_edited_merged_file_ids(self):
214
self._create_merged_file()
215
out, err = self.run_bzr('annotate file --show-ids')
150
224
def test_annotate_empty_file(self):
151
225
tree = self.make_branch_and_tree('tree')
152
226
self.build_tree_contents([('tree/empty', '')])
154
228
tree.commit('add empty file')
157
out, err = self.run_bzr('annotate', 'empty')
231
out, err = self.run_bzr('annotate empty')
232
self.assertEqual('', out)
234
def test_annotate_nonexistant_file(self):
235
tree = self.make_branch_and_tree('tree')
236
self.build_tree(['tree/file'])
238
tree.commit('add a file')
241
out, err = self.run_bzr("annotate doesnotexist", retcode=3)
242
self.assertEqual('', out)
243
self.assertEqual("bzr: ERROR: doesnotexist is not versioned.\n", err)
245
def test_annotate_without_workingtree(self):
246
tree = self.make_branch_and_tree('branch')
247
self.build_tree_contents([('branch/empty', '')])
249
tree.commit('add empty file')
250
bzrdir = tree.branch.bzrdir
251
bzrdir.destroy_workingtree()
252
self.assertFalse(bzrdir.has_workingtree())
255
out, err = self.run_bzr('annotate empty')
158
256
self.assertEqual('', out)