~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_annotate.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-02 18:29:11 UTC
  • mto: This revision was merged to the branch mainline in revision 5826.
  • Revision ID: jelmer@samba.org-20110502182911-5x8uflfjc0cnjl5n
Convert more tests to use annotate_file_revision_tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from bzrlib import (
23
23
    annotate,
 
24
    symbol_versioning,
24
25
    tests,
25
26
    )
26
27
 
297
298
        builder = self.create_merged_trees()
298
299
 
299
300
        self.assertBranchAnnotate('1     joe@foo | first\n'
300
 
                             '2     joe@foo | second\n'
301
 
                             '1.1.1 barry@f | third\n',
302
 
                             builder.get_branch(), 'a-id', 'rev-3')
 
301
                                  '2     joe@foo | second\n'
 
302
                                  '1.1.1 barry@f | third\n',
 
303
                                  builder.get_branch(), 'a-id', 'rev-3')
 
304
 
 
305
    def test_annotate_file(self):
 
306
        builder = self.create_merged_trees()
 
307
 
 
308
        to_file = StringIO()
 
309
        self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
 
310
            annotate.annotate_file, builder.get_branch(),
 
311
                'rev-3', 'a-id', to_file=to_file)
 
312
 
 
313
        self.assertAnnotateEqualDiff('1     joe@foo | first\n'
 
314
                                     '2     joe@foo | second\n'
 
315
                                     '1.1.1 barry@f | third\n',
 
316
                                     to_file.getvalue())
303
317
 
304
318
    def test_annotate_limits_dotted_revnos(self):
305
319
        """Annotate should limit dotted revnos to a depth of 12"""
306
320
        builder = self.create_deeply_merged_trees()
307
321
 
308
 
        sio = StringIO()
309
 
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
310
 
                               to_file=sio, verbose=False, full=False)
311
 
        self.assertEqualDiff('1     joe@foo | first\n'
312
 
                             '2     joe@foo | second\n'
313
 
                             '1.1.1 barry@f | third\n'
314
 
                             '1.2.1 jerry@f | fourth\n'
315
 
                             '1.3.1 george@ | fifth\n'
316
 
                             '              | sixth\n',
317
 
                             sio.getvalue())
 
322
        self.assertBranchAnnotate('1     joe@foo | first\n'
 
323
                                  '2     joe@foo | second\n'
 
324
                                  '1.1.1 barry@f | third\n'
 
325
                                  '1.2.1 jerry@f | fourth\n'
 
326
                                  '1.3.1 george@ | fifth\n'
 
327
                                  '              | sixth\n',
 
328
                                  builder.get_branch(), 'a-id', 'rev-6',
 
329
                                  verbose=False, full=False)
318
330
 
319
 
        sio = StringIO()
320
 
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
321
 
                               to_file=sio, verbose=False, full=True)
322
 
        self.assertEqualDiff('1     joe@foo | first\n'
323
 
                             '2     joe@foo | second\n'
324
 
                             '1.1.1 barry@f | third\n'
325
 
                             '1.2.1 jerry@f | fourth\n'
326
 
                             '1.3.1 george@ | fifth\n'
327
 
                             '1.3.1 george@ | sixth\n',
328
 
                             sio.getvalue())
 
331
        self.assertBranchAnnotate('1     joe@foo | first\n'
 
332
                                  '2     joe@foo | second\n'
 
333
                                  '1.1.1 barry@f | third\n'
 
334
                                  '1.2.1 jerry@f | fourth\n'
 
335
                                  '1.3.1 george@ | fifth\n'
 
336
                                  '1.3.1 george@ | sixth\n',
 
337
                                  builder.get_branch(), 'a-id', 'rev-6',
 
338
                                  verbose=False, full=True)
329
339
 
330
340
        # verbose=True shows everything, the full revno, user id, and date
331
 
        sio = StringIO()
332
 
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
333
 
                               to_file=sio, verbose=True, full=False)
334
 
        self.assertEqualDiff('1     joe@foo.com    20061213 | first\n'
335
 
                             '2     joe@foo.com    20061213 | second\n'
336
 
                             '1.1.1 barry@foo.com  20061213 | third\n'
337
 
                             '1.2.1 jerry@foo.com  20061213 | fourth\n'
338
 
                             '1.3.1 george@foo.com 20061213 | fifth\n'
339
 
                             '                              | sixth\n',
340
 
                             sio.getvalue())
 
341
        self.assertBranchAnnotate('1     joe@foo.com    20061213 | first\n'
 
342
                                  '2     joe@foo.com    20061213 | second\n'
 
343
                                  '1.1.1 barry@foo.com  20061213 | third\n'
 
344
                                  '1.2.1 jerry@foo.com  20061213 | fourth\n'
 
345
                                  '1.3.1 george@foo.com 20061213 | fifth\n'
 
346
                                  '                              | sixth\n',
 
347
                                  builder.get_branch(), 'a-id', 'rev-6',
 
348
                                  verbose=True, full=False)
341
349
 
342
 
        sio = StringIO()
343
 
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
344
 
                               to_file=sio, verbose=True, full=True)
345
 
        self.assertEqualDiff('1     joe@foo.com    20061213 | first\n'
346
 
                             '2     joe@foo.com    20061213 | second\n'
347
 
                             '1.1.1 barry@foo.com  20061213 | third\n'
348
 
                             '1.2.1 jerry@foo.com  20061213 | fourth\n'
349
 
                             '1.3.1 george@foo.com 20061213 | fifth\n'
350
 
                             '1.3.1 george@foo.com 20061213 | sixth\n',
351
 
                             sio.getvalue())
 
350
        self.assertBranchAnnotate('1     joe@foo.com    20061213 | first\n'
 
351
                                  '2     joe@foo.com    20061213 | second\n'
 
352
                                  '1.1.1 barry@foo.com  20061213 | third\n'
 
353
                                  '1.2.1 jerry@foo.com  20061213 | fourth\n'
 
354
                                  '1.3.1 george@foo.com 20061213 | fifth\n'
 
355
                                  '1.3.1 george@foo.com 20061213 | sixth\n',
 
356
                                  builder.get_branch(), 'a-id', 'rev-6',
 
357
                                  verbose=True, full=True)
352
358
 
353
359
    def test_annotate_uses_branch_context(self):
354
360
        """Dotted revnos should use the Branch context.
358
364
        """
359
365
        builder = self.create_deeply_merged_trees()
360
366
 
361
 
        sio = StringIO()
362
 
        annotate.annotate_file(builder.get_branch(), 'rev-1_3_1', 'a-id',
363
 
                               to_file=sio, verbose=False, full=False)
364
 
        self.assertEqualDiff('1     joe@foo | first\n'
365
 
                             '1.1.1 barry@f | third\n'
366
 
                             '1.2.1 jerry@f | fourth\n'
367
 
                             '1.3.1 george@ | fifth\n'
368
 
                             '              | sixth\n',
369
 
                             sio.getvalue())
 
367
        self.assertBranchAnnotate('1     joe@foo | first\n'
 
368
                                  '1.1.1 barry@f | third\n'
 
369
                                  '1.2.1 jerry@f | fourth\n'
 
370
                                  '1.3.1 george@ | fifth\n'
 
371
                                  '              | sixth\n',
 
372
                                  builder.get_branch(), 'a-id', 'rev-1_3_1',
 
373
                                  verbose=False, full=False)
370
374
 
371
375
    def test_annotate_show_ids(self):
372
376
        builder = self.create_deeply_merged_trees()
373
377
 
374
 
        sio = StringIO()
375
 
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
376
 
                               to_file=sio, show_ids=True, full=False)
377
 
 
378
378
        # It looks better with real revision ids :)
379
 
        self.assertEqualDiff('    rev-1 | first\n'
380
 
                             '    rev-2 | second\n'
381
 
                             'rev-1_1_1 | third\n'
382
 
                             'rev-1_2_1 | fourth\n'
383
 
                             'rev-1_3_1 | fifth\n'
384
 
                             '          | sixth\n',
385
 
                             sio.getvalue())
386
 
 
387
 
        sio = StringIO()
388
 
        annotate.annotate_file(builder.get_branch(), 'rev-6', 'a-id',
389
 
                               to_file=sio, show_ids=True, full=True)
390
 
 
391
 
        self.assertEqualDiff('    rev-1 | first\n'
392
 
                             '    rev-2 | second\n'
393
 
                             'rev-1_1_1 | third\n'
394
 
                             'rev-1_2_1 | fourth\n'
395
 
                             'rev-1_3_1 | fifth\n'
396
 
                             'rev-1_3_1 | sixth\n',
397
 
                             sio.getvalue())
 
379
        self.assertBranchAnnotate('    rev-1 | first\n'
 
380
                                  '    rev-2 | second\n'
 
381
                                  'rev-1_1_1 | third\n'
 
382
                                  'rev-1_2_1 | fourth\n'
 
383
                                  'rev-1_3_1 | fifth\n'
 
384
                                  '          | sixth\n',
 
385
                                  builder.get_branch(), 'a-id', 'rev-6',
 
386
                                  show_ids=True, full=False)
 
387
 
 
388
        self.assertBranchAnnotate('    rev-1 | first\n'
 
389
                                  '    rev-2 | second\n'
 
390
                                  'rev-1_1_1 | third\n'
 
391
                                  'rev-1_2_1 | fourth\n'
 
392
                                  'rev-1_3_1 | fifth\n'
 
393
                                  'rev-1_3_1 | sixth\n',
 
394
                                  builder.get_branch(), 'a-id', 'rev-6',
 
395
                                  show_ids=True, full=True)
398
396
 
399
397
    def test_annotate_unicode_author(self):
400
398
        tree1 = self.make_branch_and_tree('tree1')