280
280
if actual != expected:
281
281
# Create an easier to understand diff when the lines don't actually
283
self.assertEqualDiff(b''.join('\t'.join(l) for l in expected),
284
b''.join('\t'.join(l) for l in actual))
283
self.assertEqualDiff(''.join('\t'.join(l) for l in expected),
284
''.join('\t'.join(l) for l in actual))
286
286
def assertBranchAnnotate(self, expected, branch, path, revision_id,
287
287
verbose=False, full=False, show_ids=False):
288
288
tree = branch.repository.revision_tree(revision_id)
290
290
annotate.annotate_file_tree(tree, path, to_file,
291
291
verbose=verbose, full=full, show_ids=show_ids, branch=branch)
292
292
self.assertAnnotateEqualDiff(to_file.getvalue(), expected)
312
312
def test_annotate_shows_dotted_revnos(self):
313
313
builder = self.create_merged_trees()
315
self.assertBranchAnnotate(b'1 joe@foo | first\n'
316
b'2 joe@foo | second\n'
317
b'1.1.1 barry@f | third\n',
315
self.assertBranchAnnotate('1 joe@foo | first\n'
316
'2 joe@foo | second\n'
317
'1.1.1 barry@f | third\n',
318
318
builder.get_branch(), 'a', b'rev-3')
320
320
def test_annotate_limits_dotted_revnos(self):
321
321
"""Annotate should limit dotted revnos to a depth of 12"""
322
322
builder = self.create_deeply_merged_trees()
324
self.assertBranchAnnotate(b'1 joe@foo | first\n'
325
b'2 joe@foo | second\n'
326
b'1.1.1 barry@f | third\n'
327
b'1.2.1 jerry@f | fourth\n'
328
b'1.3.1 george@ | fifth\n'
324
self.assertBranchAnnotate('1 joe@foo | first\n'
325
'2 joe@foo | second\n'
326
'1.1.1 barry@f | third\n'
327
'1.2.1 jerry@f | fourth\n'
328
'1.3.1 george@ | fifth\n'
330
330
builder.get_branch(), 'a', b'rev-6',
331
331
verbose=False, full=False)
333
self.assertBranchAnnotate(b'1 joe@foo | first\n'
334
b'2 joe@foo | second\n'
335
b'1.1.1 barry@f | third\n'
336
b'1.2.1 jerry@f | fourth\n'
337
b'1.3.1 george@ | fifth\n'
338
b'1.3.1 george@ | sixth\n',
333
self.assertBranchAnnotate('1 joe@foo | first\n'
334
'2 joe@foo | second\n'
335
'1.1.1 barry@f | third\n'
336
'1.2.1 jerry@f | fourth\n'
337
'1.3.1 george@ | fifth\n'
338
'1.3.1 george@ | sixth\n',
339
339
builder.get_branch(), 'a', b'rev-6',
340
340
verbose=False, full=True)
342
342
# verbose=True shows everything, the full revno, user id, and date
343
self.assertBranchAnnotate(b'1 joe@foo.com 20061213 | first\n'
344
b'2 joe@foo.com 20061213 | second\n'
345
b'1.1.1 barry@foo.com 20061213 | third\n'
346
b'1.2.1 jerry@foo.com 20061213 | fourth\n'
347
b'1.3.1 george@foo.com 20061213 | fifth\n'
343
self.assertBranchAnnotate('1 joe@foo.com 20061213 | first\n'
344
'2 joe@foo.com 20061213 | second\n'
345
'1.1.1 barry@foo.com 20061213 | third\n'
346
'1.2.1 jerry@foo.com 20061213 | fourth\n'
347
'1.3.1 george@foo.com 20061213 | fifth\n'
349
349
builder.get_branch(), 'a', b'rev-6',
350
350
verbose=True, full=False)
352
self.assertBranchAnnotate(b'1 joe@foo.com 20061213 | first\n'
353
b'2 joe@foo.com 20061213 | second\n'
354
b'1.1.1 barry@foo.com 20061213 | third\n'
355
b'1.2.1 jerry@foo.com 20061213 | fourth\n'
356
b'1.3.1 george@foo.com 20061213 | fifth\n'
357
b'1.3.1 george@foo.com 20061213 | sixth\n',
352
self.assertBranchAnnotate('1 joe@foo.com 20061213 | first\n'
353
'2 joe@foo.com 20061213 | second\n'
354
'1.1.1 barry@foo.com 20061213 | third\n'
355
'1.2.1 jerry@foo.com 20061213 | fourth\n'
356
'1.3.1 george@foo.com 20061213 | fifth\n'
357
'1.3.1 george@foo.com 20061213 | sixth\n',
358
358
builder.get_branch(), 'a', b'rev-6',
359
359
verbose=True, full=True)
367
367
builder = self.create_deeply_merged_trees()
369
self.assertBranchAnnotate(b'1 joe@foo | first\n'
370
b'1.1.1 barry@f | third\n'
371
b'1.2.1 jerry@f | fourth\n'
372
b'1.3.1 george@ | fifth\n'
369
self.assertBranchAnnotate('1 joe@foo | first\n'
370
'1.1.1 barry@f | third\n'
371
'1.2.1 jerry@f | fourth\n'
372
'1.3.1 george@ | fifth\n'
374
374
builder.get_branch(), 'a', b'rev-1_3_1',
375
375
verbose=False, full=False)
378
378
builder = self.create_deeply_merged_trees()
380
380
# It looks better with real revision ids :)
381
self.assertBranchAnnotate(b' rev-1 | first\n'
383
b'rev-1_1_1 | third\n'
384
b'rev-1_2_1 | fourth\n'
385
b'rev-1_3_1 | fifth\n'
381
self.assertBranchAnnotate(' rev-1 | first\n'
383
'rev-1_1_1 | third\n'
384
'rev-1_2_1 | fourth\n'
385
'rev-1_3_1 | fifth\n'
387
387
builder.get_branch(), 'a', b'rev-6',
388
388
show_ids=True, full=False)
390
self.assertBranchAnnotate(b' rev-1 | first\n'
392
b'rev-1_1_1 | third\n'
393
b'rev-1_2_1 | fourth\n'
394
b'rev-1_3_1 | fifth\n'
395
b'rev-1_3_1 | sixth\n',
390
self.assertBranchAnnotate(' rev-1 | first\n'
392
'rev-1_1_1 | third\n'
393
'rev-1_2_1 | fourth\n'
394
'rev-1_3_1 | fifth\n'
395
'rev-1_3_1 | sixth\n',
396
396
builder.get_branch(), 'a', b'rev-6',
397
397
show_ids=True, full=True)
418
418
revtree_2 = tree1.branch.repository.revision_tree(b'rev-2')
420
420
# this passes if no exception is raised
422
422
annotate.annotate_file_tree(revtree_1, 'a',
423
423
to_file=to_file, branch=tree1.branch)
426
426
to_file = codecs.getwriter('ascii')(sio, 'replace')
427
427
annotate.annotate_file_tree(revtree_2, 'b',
428
428
to_file=to_file, branch=tree1.branch)
429
self.assertEqualDiff(b'2 p?rez | bye\n', sio.getvalue())
429
self.assertEqualDiff('2 p?rez | bye\n', sio.getvalue())
431
431
# test now with unicode file-like
432
432
to_file = StringIOWithEncoding()