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