/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 bzrlib/tests/test_log.py

  • Committer: Ian Clatworthy
  • Date: 2007-08-28 06:43:19 UTC
  • mfrom: (2671.5.8 author-2)
  • mto: This revision was merged to the branch mainline in revision 2757.
  • Revision ID: ian.clatworthy@internode.on.net-20070828064319-g8nl209v23jx0i62
(Lukáš Lalinský) Display the author instead of the committer in bzr log and bzr annotate

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from cStringIO import StringIO
19
19
 
20
20
from bzrlib import log
21
 
from bzrlib.tests import TestCaseWithTransport
 
21
from bzrlib.tests import TestCase, TestCaseWithTransport
22
22
from bzrlib.log import (show_log,
23
23
                        get_view_revisions,
24
24
                        LogRevision,
28
28
                        LineLogFormatter)
29
29
from bzrlib.branch import Branch
30
30
from bzrlib.errors import InvalidRevisionNumber
 
31
from bzrlib.revision import Revision
31
32
 
32
33
 
33
34
class LogCatcher(LogFormatter):
200
201
    b.nick='test'
201
202
    open('a', 'wb').write('hello moto\n')
202
203
    wt.add('a')
203
 
    wt.commit('simple log message', rev_id='a1'
204
 
            , timestamp=1132586655.459960938, timezone=-6*3600
205
 
            , committer='Joe Foo <joe@foo.com>')
 
204
    wt.commit('simple log message', rev_id='a1',
 
205
              timestamp=1132586655.459960938, timezone=-6*3600,
 
206
              committer='Joe Foo <joe@foo.com>')
206
207
    open('b', 'wb').write('goodbye\n')
207
208
    wt.add('b')
208
 
    wt.commit('multiline\nlog\nmessage\n', rev_id='a2'
209
 
            , timestamp=1132586842.411175966, timezone=-6*3600
210
 
            , committer='Joe Foo <joe@foo.com>')
 
209
    wt.commit('multiline\nlog\nmessage\n', rev_id='a2',
 
210
              timestamp=1132586842.411175966, timezone=-6*3600,
 
211
              committer='Joe Foo <joe@foo.com>',
 
212
              author='Joe Bar <joe@bar.com>')
211
213
 
212
214
    open('c', 'wb').write('just another manic monday\n')
213
215
    wt.add('c')
214
 
    wt.commit('single line with trailing newline\n', rev_id='a3'
215
 
            , timestamp=1132587176.835228920, timezone=-6*3600
216
 
            , committer = 'Joe Foo <joe@foo.com>')
 
216
    wt.commit('single line with trailing newline\n', rev_id='a3',
 
217
              timestamp=1132587176.835228920, timezone=-6*3600,
 
218
              committer = 'Joe Foo <joe@foo.com>')
217
219
    return b
218
220
 
219
221
 
229
231
    3 Joe Foo\t2005-11-21
230
232
      single line with trailing newline
231
233
 
232
 
    2 Joe Foo\t2005-11-21
 
234
    2 Joe Bar\t2005-11-21
233
235
      multiline
234
236
      log
235
237
      message
244
246
 
245
247
    def normalize_log(self,log):
246
248
        """Replaces the variable lines of logs with fixed lines"""
 
249
        author = 'author: Dolor Sit <test@example.com>'
247
250
        committer = 'committer: Lorem Ipsum <test@example.com>'
248
251
        lines = log.splitlines(True)
249
252
        for idx,line in enumerate(lines):
250
253
            stripped_line = line.lstrip()
251
254
            indent = ' ' * (len(line) - len(stripped_line))
252
 
            if stripped_line.startswith('committer:'):
 
255
            if stripped_line.startswith('author:'):
 
256
                lines[idx] = indent + author + '\n'
 
257
            elif stripped_line.startswith('committer:'):
253
258
                lines[idx] = indent + committer + '\n'
254
 
            if stripped_line.startswith('timestamp:'):
 
259
            elif stripped_line.startswith('timestamp:'):
255
260
                lines[idx] = indent + 'timestamp: Just now\n'
256
261
        return ''.join(lines)
257
262
 
414
419
  single line with trailing newline
415
420
------------------------------------------------------------
416
421
revno: 2
 
422
author: Joe Bar <joe@bar.com>
417
423
committer: Joe Foo <joe@foo.com>
418
424
branch nick: test
419
425
timestamp: Mon 2005-11-21 09:27:22 -0600
450
456
        self.assertEqualDiff(sio.getvalue(), '''\
451
457
------------------------------------------------------------
452
458
revno: 1
453
 
committer: Lorem Ipsum <test@example.com>
454
459
author: John Doe <jdoe@example.com>
 
460
committer: Lorem Ipsum <test@example.com>
455
461
branch nick: test_author_log
456
462
timestamp: Wed 2005-11-23 12:08:27 +1000
457
463
message:
523
529
        show_log(b, lf)
524
530
        self.assertEqualDiff(sio.getvalue(), """\
525
531
3: Joe Foo 2005-11-21 single line with trailing newline
526
 
2: Joe Foo 2005-11-21 multiline
 
532
2: Joe Bar 2005-11-21 multiline
527
533
1: Joe Foo 2005-11-21 simple log message
528
534
""")
529
535
 
791
797
        log.show_changed_revisions(tree.branch, [], ['bar-id'], s)
792
798
        self.assertContainsRe(s.getvalue(), 'bar')
793
799
        self.assertNotContainsRe(s.getvalue(), 'foo')
 
800
 
 
801
 
 
802
class TestLogFormatter(TestCase):
 
803
 
 
804
    def test_short_committer(self):
 
805
        rev = Revision('a-id')
 
806
        rev.committer = 'John Doe <jdoe@example.com>'
 
807
        lf = LogFormatter(None)
 
808
        self.assertEqual('John Doe', lf.short_committer(rev))
 
809
 
 
810
    def test_short_author(self):
 
811
        rev = Revision('a-id')
 
812
        rev.committer = 'John Doe <jdoe@example.com>'
 
813
        lf = LogFormatter(None)
 
814
        self.assertEqual('John Doe', lf.short_author(rev))
 
815
        rev.properties['author'] = 'John Smith <jsmith@example.com>'
 
816
        self.assertEqual('John Smith', lf.short_author(rev))