/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-07-25 00:54:22 UTC
  • mfrom: (7045.1.23 python3-p)
  • Revision ID: breezy.the.bot@gmail.com-20180725005422-a1rubn7zssfn2uvu
Fix some more tests on Python 3.

Merged from https://code.launchpad.net/~jelmer/brz/python3-p/+merge/349784

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    tests,
24
24
    )
25
25
from ..sixish import (
26
 
    BytesIO,
 
26
    StringIO,
27
27
    )
28
28
from .ui_testing import StringIOWithEncoding
29
29
 
280
280
        if actual != expected:
281
281
            # Create an easier to understand diff when the lines don't actually
282
282
            # match
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))
285
285
 
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)
289
 
        to_file = BytesIO()
 
289
        to_file = StringIO()
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()
314
314
 
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')
319
319
 
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()
323
323
 
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'
329
 
                                  b'              | sixth\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'
 
329
                                  '              | sixth\n',
330
330
                                  builder.get_branch(), 'a', b'rev-6',
331
331
                                  verbose=False, full=False)
332
332
 
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)
341
341
 
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'
348
 
                                  b'                              | sixth\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'
 
348
                                  '                              | sixth\n',
349
349
                                  builder.get_branch(), 'a', b'rev-6',
350
350
                                  verbose=True, full=False)
351
351
 
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)
360
360
 
366
366
        """
367
367
        builder = self.create_deeply_merged_trees()
368
368
 
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'
373
 
                                  b'              | sixth\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'
 
373
                                  '              | sixth\n',
374
374
                                  builder.get_branch(), 'a', b'rev-1_3_1',
375
375
                                  verbose=False, full=False)
376
376
 
378
378
        builder = self.create_deeply_merged_trees()
379
379
 
380
380
        # It looks better with real revision ids :)
381
 
        self.assertBranchAnnotate(b'    rev-1 | first\n'
382
 
                                  b'    rev-2 | second\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'
386
 
                                  b'          | sixth\n',
 
381
        self.assertBranchAnnotate('    rev-1 | first\n'
 
382
                                  '    rev-2 | second\n'
 
383
                                  'rev-1_1_1 | third\n'
 
384
                                  'rev-1_2_1 | fourth\n'
 
385
                                  'rev-1_3_1 | fifth\n'
 
386
                                  '          | sixth\n',
387
387
                                  builder.get_branch(), 'a', b'rev-6',
388
388
                                  show_ids=True, full=False)
389
389
 
390
 
        self.assertBranchAnnotate(b'    rev-1 | first\n'
391
 
                                  b'    rev-2 | second\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'
 
391
                                  '    rev-2 | second\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)
398
398
 
418
418
        revtree_2 = tree1.branch.repository.revision_tree(b'rev-2')
419
419
 
420
420
        # this passes if no exception is raised
421
 
        to_file = BytesIO()
 
421
        to_file = StringIO()
422
422
        annotate.annotate_file_tree(revtree_1, 'a',
423
423
            to_file=to_file, branch=tree1.branch)
424
424
 
425
 
        sio = BytesIO()
 
425
        sio = StringIO()
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())
430
430
 
431
431
        # test now with unicode file-like
432
432
        to_file = StringIOWithEncoding()
453
453
        tree1.lock_read()
454
454
        self.addCleanup(tree1.unlock)
455
455
 
456
 
        self.assertBranchAnnotate(b'1   committ | hello\n', tree1.branch,
 
456
        self.assertBranchAnnotate('1   committ | hello\n', tree1.branch,
457
457
            'a', b'rev-1')
458
458
 
459
 
        self.assertBranchAnnotate(b'2   author@ | bye\n', tree1.branch,
 
459
        self.assertBranchAnnotate('2   author@ | bye\n', tree1.branch,
460
460
            'b', b'rev-2')
461
461
 
462
462