/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: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
        """
225
225
        builder = self.create_merged_trees()
226
226
        builder.build_snapshot([b'rev-1_1_1'], [], revision_id=b'rev-1_1_2')
227
 
        builder.build_snapshot([b'rev-3', b'rev-1_1_2'], [], revision_id=b'rev-4')
 
227
        builder.build_snapshot([b'rev-3', b'rev-1_1_2'],
 
228
                               [], revision_id=b'rev-4')
228
229
        builder.build_snapshot([b'rev-1_1_1'], [
229
230
            ('modify', ('a', b'first\nthird\nfourth\n')),
230
231
            ], timestamp=1166046003.00, timezone=0, committer="jerry@foo.com",
231
232
            revision_id=b'rev-1_2_1')
232
233
        builder.build_snapshot([b'rev-1_2_1'], [],
233
 
            timestamp=1166046004.00, timezone=0, committer="jerry@foo.com",
234
 
            revision_id=b'rev-1_2_2')
 
234
                               timestamp=1166046004.00, timezone=0, committer="jerry@foo.com",
 
235
                               revision_id=b'rev-1_2_2')
235
236
        builder.build_snapshot([b'rev-4', b'rev-1_2_2'], [
236
237
            ('modify', ('a', b'first\nsecond\nthird\nfourth\n')),
237
238
            ], timestamp=1166046004.00, timezone=0, committer="jerry@foo.com",
285
286
                                 ''.join('\t'.join(l) for l in actual))
286
287
 
287
288
    def assertBranchAnnotate(self, expected, branch, path, revision_id,
288
 
            verbose=False, full=False, show_ids=False):
 
289
                             verbose=False, full=False, show_ids=False):
289
290
        tree = branch.repository.revision_tree(revision_id)
290
291
        to_file = StringIO()
291
292
        annotate.annotate_file_tree(tree, path, to_file,
292
 
            verbose=verbose, full=full, show_ids=show_ids, branch=branch)
 
293
                                    verbose=verbose, full=full, show_ids=show_ids, branch=branch)
293
294
        self.assertAnnotateEqualDiff(to_file.getvalue(), expected)
294
295
 
295
296
    def assertRepoAnnotate(self, expected, repo, path, revision_id):
421
422
        # this passes if no exception is raised
422
423
        to_file = StringIO()
423
424
        annotate.annotate_file_tree(revtree_1, 'a',
424
 
            to_file=to_file, branch=tree1.branch)
 
425
                                    to_file=to_file, branch=tree1.branch)
425
426
 
426
427
        sio = BytesIO()
427
428
        to_file = codecs.getwriter('ascii')(sio, 'replace')
428
429
        annotate.annotate_file_tree(revtree_2, 'b',
429
 
            to_file=to_file, branch=tree1.branch)
 
430
                                    to_file=to_file, branch=tree1.branch)
430
431
        self.assertEqualDiff(b'2   p?rez   | bye\n', sio.getvalue())
431
432
 
432
433
        # test now with unicode file-like
433
434
        to_file = StringIOWithEncoding()
434
435
        annotate.annotate_file_tree(revtree_2, 'b',
435
 
            to_file=to_file, branch=tree1.branch)
 
436
                                    to_file=to_file, branch=tree1.branch)
436
437
        self.assertContainsRe(u'2   p\xe9rez   | bye\n', to_file.getvalue())
437
438
 
438
439
    def test_annotate_author_or_committer(self):
455
456
        self.addCleanup(tree1.unlock)
456
457
 
457
458
        self.assertBranchAnnotate('1   committ | hello\n', tree1.branch,
458
 
            'a', b'rev-1')
 
459
                                  'a', b'rev-1')
459
460
 
460
461
        self.assertBranchAnnotate('2   author@ | bye\n', tree1.branch,
461
 
            'b', b'rev-2')
 
462
                                  'b', b'rev-2')
462
463
 
463
464
 
464
465
class TestReannotate(tests.TestCase):
466
467
    def annotateEqual(self, expected, parents, newlines, revision_id,
467
468
                      blocks=None):
468
469
        annotate_list = list(annotate.reannotate(parents, newlines,
469
 
                             revision_id, blocks))
 
470
                                                 revision_id, blocks))
470
471
        self.assertEqual(len(expected), len(annotate_list))
471
472
        for e, a in zip(expected, annotate_list):
472
473
            self.assertEqual(e, a)