18
18
from cStringIO import StringIO
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,
201
202
open('a', 'wb').write('hello moto\n')
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')
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>')
212
214
open('c', 'wb').write('just another manic monday\n')
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>')
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)
414
419
single line with trailing newline
415
420
------------------------------------------------------------
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
------------------------------------------------------------
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
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
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')
802
class TestLogFormatter(TestCase):
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))
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))