41
class TestCaseWithoutPropsHandler(TestCaseWithTransport):
44
super(TestCaseWithoutPropsHandler, self).setUp()
45
# keep a reference to the "current" custom prop. handler registry
46
self.properties_handler_registry = \
47
log.properties_handler_registry
48
# clean up the registry in log
49
log.properties_handler_registry = registry.Registry()
52
super(TestLongLogFormatter, self).tearDown()
53
# restore the custom properties handler registry
54
log.properties_handler_registry = \
55
self.properties_handler_registry
41
58
class LogCatcher(LogFormatter):
42
59
"""Pull log messages into list rather than displaying them.
581
def test_properties_in_log(self):
582
"""Log includes the custom properties returned by the registered
585
wt = self.make_branch_and_tree('.')
587
self.build_tree(['a'])
589
b.nick = 'test_author_log'
590
wt.commit(message='add a',
591
timestamp=1132711707,
593
committer='Lorem Ipsum <test@example.com>',
594
author='John Doe <jdoe@example.com>')
596
formatter = LongLogFormatter(to_file=sio)
598
def trivial_custom_prop_handler(revision):
599
return {'test_prop':'test_value'}
601
log.properties_handler_registry.register(
602
'trivial_custom_prop_handler',
603
trivial_custom_prop_handler)
604
show_log(b, formatter)
606
log.properties_handler_registry.remove(
607
'trivial_custom_prop_handler')
608
self.assertEqualDiff(sio.getvalue(), '''\
609
------------------------------------------------------------
611
test_prop: test_value
612
author: John Doe <jdoe@example.com>
613
committer: Lorem Ipsum <test@example.com>
614
branch nick: test_author_log
615
timestamp: Wed 2005-11-23 12:08:27 +1000
620
def test_error_in_properties_handler(self):
621
"""Log includes the custom properties returned by the registered
624
wt = self.make_branch_and_tree('.')
626
self.build_tree(['a'])
628
b.nick = 'test_author_log'
629
wt.commit(message='add a',
630
timestamp=1132711707,
632
committer='Lorem Ipsum <test@example.com>',
633
author='John Doe <jdoe@example.com>',
634
revprops={'first_prop':'first_value'})
636
formatter = LongLogFormatter(to_file=sio)
638
def trivial_custom_prop_handler(revision):
639
raise StandardError("a test error")
641
log.properties_handler_registry.register(
642
'trivial_custom_prop_handler',
643
trivial_custom_prop_handler)
644
self.assertRaises(StandardError, show_log, b, formatter,)
646
log.properties_handler_registry.remove(
647
'trivial_custom_prop_handler')
566
650
class TestLineLogFormatter(TestCaseWithTransport):