~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Guillermo Gonzalez
  • Date: 2008-03-31 03:56:49 UTC
  • mto: (3542.1.1 logdisplayers)
  • mto: This revision was merged to the branch mainline in revision 3556.
  • Revision ID: guillo.gonzo@gmail.com-20080331035649-y732vhbondfc3w6k
 * added error handling (and logging) to LogFormatter.show_properties when a handler raise an error
 * added test case for broken and missing handler

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
    config,
64
64
    lazy_regex,
65
65
    registry,
 
66
    trace,
66
67
    )
67
68
from bzrlib.errors import (
68
69
    BzrCommandError,
635
636
        return address
636
637
 
637
638
    def show_properties(self, properties):
638
 
        """Display the custom properties returned by each 
639
 
        registered function.
 
639
        """Displays the custom properties returned by each registered handler.
 
640
        
 
641
        If a registered handler raise an error, it's silently logged and the
 
642
        next handler in the registry is executed.
640
643
        """
641
644
        filtered_props = properties.copy()
642
 
        if filtered_props.has_key('branch-nick'): 
 
645
        if 'branch-nick' in filtered_props: 
643
646
            del filtered_props['branch-nick']
644
 
        for key, function in custom_properties_handler_registry.iteritems():
645
 
            for key, value in function(filtered_props).items():
646
 
                self.to_file.write(key + ': ' + value + '\n')
 
647
        for key, handler in custom_properties_handler_registry.iteritems():
 
648
            try:
 
649
                for key, value in handler(filtered_props).items():
 
650
                    self.to_file.write(key + ': ' + value + '\n')
 
651
            except:
 
652
                mutter('custom property handler: %s raised an error', 
 
653
                        key)
 
654
                trace.log_exception_quietly()
 
655
 
647
656
 
648
657
class LongLogFormatter(LogFormatter):
649
658
 
665
674
            to_file.write('\n')
666
675
            for parent_id in revision.rev.parent_ids:
667
676
                to_file.write(indent + 'parent: %s\n' % (parent_id,))
668
 
        
669
 
        # show custom properties
670
677
        self.show_properties(revision.rev.properties)
671
678
 
672
679
        author = revision.rev.properties.get('author', None)