/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_annotate.py

  • Committer: Jelmer Vernooij
  • Date: 2017-11-19 18:35:20 UTC
  • mfrom: (6809.4.27 swap-arguments)
  • Revision ID: jelmer@jelmer.uk-20171119183520-fmw89uw30e0tbhwz
Merge lp:~jelmer/brz/swap-arguments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
283
283
            self.assertEqualDiff(''.join('\t'.join(l) for l in expected),
284
284
                                 ''.join('\t'.join(l) for l in actual))
285
285
 
286
 
    def assertBranchAnnotate(self, expected, branch, file_id, revision_id,
 
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)
289
289
        to_file = BytesIO()
290
 
        annotate.annotate_file_tree(tree, file_id, to_file,
 
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)
293
293
 
294
 
    def assertRepoAnnotate(self, expected, repo, file_id, revision_id):
 
294
    def assertRepoAnnotate(self, expected, repo, path, revision_id):
295
295
        """Assert that the revision is properly annotated."""
296
 
        actual = list(repo.revision_tree(revision_id).annotate_iter(file_id))
 
296
        actual = list(repo.revision_tree(revision_id).annotate_iter(path))
297
297
        self.assertAnnotateEqualDiff(actual, expected)
298
298
 
299
299
    def test_annotate_duplicate_lines(self):
302
302
        repo = builder.get_branch().repository
303
303
        repo.lock_read()
304
304
        self.addCleanup(repo.unlock)
305
 
        self.assertRepoAnnotate(duplicate_base, repo, 'file-id', 'rev-base')
306
 
        self.assertRepoAnnotate(duplicate_A, repo, 'file-id', 'rev-A')
307
 
        self.assertRepoAnnotate(duplicate_B, repo, 'file-id', 'rev-B')
308
 
        self.assertRepoAnnotate(duplicate_C, repo, 'file-id', 'rev-C')
309
 
        self.assertRepoAnnotate(duplicate_D, repo, 'file-id', 'rev-D')
310
 
        self.assertRepoAnnotate(duplicate_E, repo, 'file-id', 'rev-E')
 
305
        self.assertRepoAnnotate(duplicate_base, repo, 'file', 'rev-base')
 
306
        self.assertRepoAnnotate(duplicate_A, repo, 'file', 'rev-A')
 
307
        self.assertRepoAnnotate(duplicate_B, repo, 'file', 'rev-B')
 
308
        self.assertRepoAnnotate(duplicate_C, repo, 'file', 'rev-C')
 
309
        self.assertRepoAnnotate(duplicate_D, repo, 'file', 'rev-D')
 
310
        self.assertRepoAnnotate(duplicate_E, repo, 'file', 'rev-E')
311
311
 
312
312
    def test_annotate_shows_dotted_revnos(self):
313
313
        builder = self.create_merged_trees()
315
315
        self.assertBranchAnnotate('1     joe@foo | first\n'
316
316
                                  '2     joe@foo | second\n'
317
317
                                  '1.1.1 barry@f | third\n',
318
 
                                  builder.get_branch(), 'a-id', 'rev-3')
 
318
                                  builder.get_branch(), 'a', 'rev-3')
319
319
 
320
320
    def test_annotate_limits_dotted_revnos(self):
321
321
        """Annotate should limit dotted revnos to a depth of 12"""
327
327
                                  '1.2.1 jerry@f | fourth\n'
328
328
                                  '1.3.1 george@ | fifth\n'
329
329
                                  '              | sixth\n',
330
 
                                  builder.get_branch(), 'a-id', 'rev-6',
 
330
                                  builder.get_branch(), 'a', 'rev-6',
331
331
                                  verbose=False, full=False)
332
332
 
333
333
        self.assertBranchAnnotate('1     joe@foo | first\n'
336
336
                                  '1.2.1 jerry@f | fourth\n'
337
337
                                  '1.3.1 george@ | fifth\n'
338
338
                                  '1.3.1 george@ | sixth\n',
339
 
                                  builder.get_branch(), 'a-id', 'rev-6',
 
339
                                  builder.get_branch(), 'a', 'rev-6',
340
340
                                  verbose=False, full=True)
341
341
 
342
342
        # verbose=True shows everything, the full revno, user id, and date
346
346
                                  '1.2.1 jerry@foo.com  20061213 | fourth\n'
347
347
                                  '1.3.1 george@foo.com 20061213 | fifth\n'
348
348
                                  '                              | sixth\n',
349
 
                                  builder.get_branch(), 'a-id', 'rev-6',
 
349
                                  builder.get_branch(), 'a', 'rev-6',
350
350
                                  verbose=True, full=False)
351
351
 
352
352
        self.assertBranchAnnotate('1     joe@foo.com    20061213 | first\n'
355
355
                                  '1.2.1 jerry@foo.com  20061213 | fourth\n'
356
356
                                  '1.3.1 george@foo.com 20061213 | fifth\n'
357
357
                                  '1.3.1 george@foo.com 20061213 | sixth\n',
358
 
                                  builder.get_branch(), 'a-id', 'rev-6',
 
358
                                  builder.get_branch(), 'a', 'rev-6',
359
359
                                  verbose=True, full=True)
360
360
 
361
361
    def test_annotate_uses_branch_context(self):
371
371
                                  '1.2.1 jerry@f | fourth\n'
372
372
                                  '1.3.1 george@ | fifth\n'
373
373
                                  '              | sixth\n',
374
 
                                  builder.get_branch(), 'a-id', 'rev-1_3_1',
 
374
                                  builder.get_branch(), 'a', 'rev-1_3_1',
375
375
                                  verbose=False, full=False)
376
376
 
377
377
    def test_annotate_show_ids(self):
384
384
                                  'rev-1_2_1 | fourth\n'
385
385
                                  'rev-1_3_1 | fifth\n'
386
386
                                  '          | sixth\n',
387
 
                                  builder.get_branch(), 'a-id', 'rev-6',
 
387
                                  builder.get_branch(), 'a', 'rev-6',
388
388
                                  show_ids=True, full=False)
389
389
 
390
390
        self.assertBranchAnnotate('    rev-1 | first\n'
393
393
                                  'rev-1_2_1 | fourth\n'
394
394
                                  'rev-1_3_1 | fifth\n'
395
395
                                  'rev-1_3_1 | sixth\n',
396
 
                                  builder.get_branch(), 'a-id', 'rev-6',
 
396
                                  builder.get_branch(), 'a', 'rev-6',
397
397
                                  show_ids=True, full=True)
398
398
 
399
399
    def test_annotate_unicode_author(self):
419
419
 
420
420
        # this passes if no exception is raised
421
421
        to_file = BytesIO()
422
 
        annotate.annotate_file_tree(revtree_1, 'a-id',
 
422
        annotate.annotate_file_tree(revtree_1, 'a',
423
423
            to_file=to_file, branch=tree1.branch)
424
424
 
425
425
        sio = BytesIO()
426
426
        to_file = codecs.getwriter('ascii')(sio, 'replace')
427
 
        annotate.annotate_file_tree(revtree_2, 'b-id',
 
427
        annotate.annotate_file_tree(revtree_2, 'b',
428
428
            to_file=to_file, branch=tree1.branch)
429
429
        self.assertEqualDiff('2   p?rez   | bye\n', sio.getvalue())
430
430
 
431
431
        # test now with unicode file-like
432
432
        to_file = StringIOWithEncoding()
433
 
        annotate.annotate_file_tree(revtree_2, 'b-id',
 
433
        annotate.annotate_file_tree(revtree_2, 'b',
434
434
            to_file=to_file, branch=tree1.branch)
435
435
        self.assertContainsRe(u'2   p\xe9rez   | bye\n', to_file.getvalue())
436
436
 
454
454
        self.addCleanup(tree1.unlock)
455
455
 
456
456
        self.assertBranchAnnotate('1   committ | hello\n', tree1.branch,
457
 
            'a-id', 'rev-1')
 
457
            'a', 'rev-1')
458
458
 
459
459
        to_file = BytesIO()
460
460
        self.assertBranchAnnotate('2   author@ | bye\n', tree1.branch,
461
 
            'b-id', 'rev-2')
 
461
            'b', 'rev-2')
462
462
 
463
463
 
464
464
class TestReannotate(tests.TestCase):