163
163
tree.commit('add file', committer="test@host", rev_id="rev1")
164
164
self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
165
tree.branch.get_config().set_user_option('email', 'current@host2')
168
167
def test_annotate_cmd_revspec_branch(self):
169
168
tree = self._setup_edited_file('trunk')
170
169
tree.branch.create_checkout(self.get_url('work'), lightweight=True)
172
out, err = self.run_bzr('annotate file -r branch:../trunk')
170
out, err = self.run_bzr(['annotate', 'file', '-r', 'branch:../trunk'],
173
172
self.assertEqual('', err)
174
173
self.assertEqual(
175
174
'1 test@ho | foo\n'
185
185
'1 test@ho | gam\n',
188
def test_annotate_edited_file_no_default(self):
189
# Ensure that when no username is available annotate still works.
190
self.overrideEnv('EMAIL', None)
191
self.overrideEnv('BZR_EMAIL', None)
192
# Also, make sure that it's not inferred from mailname.
193
self.overrideAttr(config, '_auto_user_id',
194
lambda: (None, None))
195
tree = self._setup_edited_file()
196
out, err = self.run_bzr('annotate file')
188
203
def test_annotate_edited_file_show_ids(self):
189
204
tree = self._setup_edited_file()
205
tree.branch.get_config().set_user_option('email', 'current@host2')
190
206
out, err = self.run_bzr('annotate file --show-ids')
191
207
self.assertEqual(
211
227
tree.merge_from_branch(tree.branch, "rev1.1.1")
212
228
# edit the file to be 'resolved' and have a further local edit
213
229
self.build_tree_contents([('file', 'local\nfoo\nbar\nbaz\ngam\n')])
215
232
def test_annotated_edited_merged_file_revnos(self):
216
self._create_merged_file()
217
out, err = self.run_bzr('annotate file')
218
email = extract_email_address(Branch.open('.').get_config().username())
233
wt = self._create_merged_file()
234
out, err = self.run_bzr(['annotate', 'file'])
235
email = config.extract_email_address(wt.branch.get_config().username())
219
236
self.assertEqual(
220
237
'3? %-7s | local\n'
221
238
'1 test@ho | foo\n'
238
255
def test_annotate_empty_file(self):
239
tree = self.make_branch_and_tree('tree')
240
self.build_tree_contents([('tree/empty', '')])
256
tree = self.make_branch_and_tree('.')
257
self.build_tree_contents([('empty', '')])
241
258
tree.add('empty')
242
259
tree.commit('add empty file')
260
out, err = self.run_bzr(['annotate', 'empty'])
261
self.assertEqual('', out)
245
out, err = self.run_bzr('annotate empty')
263
def test_annotate_removed_file(self):
264
tree = self.make_branch_and_tree('.')
265
self.build_tree_contents([('empty', '')])
267
tree.commit('add empty file')
270
tree.commit('remove empty file')
271
out, err = self.run_bzr(['annotate', '-r1', 'empty'])
246
272
self.assertEqual('', out)
248
274
def test_annotate_empty_file_show_ids(self):
249
tree = self.make_branch_and_tree('tree')
250
self.build_tree_contents([('tree/empty', '')])
275
tree = self.make_branch_and_tree('.')
276
self.build_tree_contents([('empty', '')])
251
277
tree.add('empty')
252
278
tree.commit('add empty file')
255
279
out, err = self.run_bzr(['annotate', '--show-ids', 'empty'])
256
280
self.assertEqual('', out)
258
282
def test_annotate_nonexistant_file(self):
259
tree = self.make_branch_and_tree('tree')
260
self.build_tree(['tree/file'])
283
tree = self.make_branch_and_tree('.')
284
self.build_tree(['file'])
261
285
tree.add(['file'])
262
286
tree.commit('add a file')
265
out, err = self.run_bzr("annotate doesnotexist", retcode=3)
287
out, err = self.run_bzr(['annotate', 'doesnotexist'], retcode=3)
266
288
self.assertEqual('', out)
267
289
self.assertEqual("bzr: ERROR: doesnotexist is not versioned.\n", err)
269
291
def test_annotate_without_workingtree(self):
270
tree = self.make_branch_and_tree('branch')
271
self.build_tree_contents([('branch/empty', '')])
292
tree = self.make_branch_and_tree('.')
293
self.build_tree_contents([('empty', '')])
272
294
tree.add('empty')
273
295
tree.commit('add empty file')
274
296
bzrdir = tree.branch.bzrdir
275
297
bzrdir.destroy_workingtree()
276
298
self.assertFalse(bzrdir.has_workingtree())
279
out, err = self.run_bzr('annotate empty')
299
out, err = self.run_bzr(['annotate', 'empty'])
280
300
self.assertEqual('', out)
282
302
def test_annotate_directory(self):
285
305
self.build_tree_contents([('a/hello.txt', 'my helicopter\n')])
286
306
wt.add(['hello.txt'])
287
307
wt.commit('commit', committer='test@user')
288
out, err = self.run_bzr('annotate -d a hello.txt')
308
out, err = self.run_bzr(['annotate', '-d', 'a', 'hello.txt'])
289
309
self.assertEqualDiff('1 test@us | my helicopter\n', out)