~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-02-08 13:33:08 UTC
  • mfrom: (3976.3.3 short-log-foreign)
  • Revision ID: pqm@pqm.ubuntu.com-20090208133308-rn4wcu897hduyl2d
(Neil Martinsen-Burrell) Add custom properties handling to short log
        format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
735
735
''',
736
736
                                 sio.getvalue())
737
737
 
 
738
    def test_properties_in_short_log(self):
 
739
        """Log includes the custom properties returned by the registered 
 
740
        handlers.
 
741
        """
 
742
        wt = self.make_branch_and_tree('.')
 
743
        b = wt.branch
 
744
        self.build_tree(['a'])
 
745
        wt.add('a')
 
746
        b.nick = 'test_properties_in_short_log'
 
747
        wt.commit(message='add a',
 
748
                  timestamp=1132711707,
 
749
                  timezone=36000,
 
750
                  committer='Lorem Ipsum <test@example.com>',
 
751
                  author='John Doe <jdoe@example.com>')
 
752
        sio = StringIO()
 
753
        formatter = log.ShortLogFormatter(to_file=sio)
 
754
        try:
 
755
            def trivial_custom_prop_handler(revision):
 
756
                return {'test_prop':'test_value'}
 
757
 
 
758
            log.properties_handler_registry.register(
 
759
                'trivial_custom_prop_handler',
 
760
                trivial_custom_prop_handler)
 
761
            log.show_log(b, formatter)
 
762
        finally:
 
763
            log.properties_handler_registry.remove(
 
764
                'trivial_custom_prop_handler')
 
765
            self.assertEqualDiff('''\
 
766
    1 John Doe\t2005-11-23
 
767
      test_prop: test_value
 
768
      add a
 
769
 
 
770
''',
 
771
                                 sio.getvalue())
 
772
 
738
773
    def test_error_in_properties_handler(self):
739
774
        """Log includes the custom properties returned by the registered 
740
775
        handlers.