~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-17 09:58:00 UTC
  • mfrom: (3542.1.1 logdisplayers)
  • Revision ID: pqm@pqm.ubuntu.com-20080717095800-b6c3hdb60qazu5am
(Guillermo Gonzalez) Custom displayers for log.

Show diffs side-by-side

added added

removed removed

Lines of Context:
615
615
        only relevant if supports_merge_revisions is not True.
616
616
    - supports_tags must be True if this log formatter supports tags.
617
617
        Otherwise the tags attribute may not be populated.
 
618
 
 
619
    Plugins can register functions to show custom revision properties using
 
620
    the properties_handler_registry. The registered function
 
621
    must respect the following interface description:
 
622
        def my_show_properties(properties_dict):
 
623
            # code that returns a dict {'name':'value'} of the properties 
 
624
            # to be shown
618
625
    """
619
626
 
620
627
    def __init__(self, to_file, show_ids=False, show_timezone='original'):
644
651
            return name
645
652
        return address
646
653
 
 
654
    def show_properties(self, revision, indent):
 
655
        """Displays the custom properties returned by each registered handler.
 
656
        
 
657
        If a registered handler raises an error it is propagated.
 
658
        """
 
659
        for key, handler in properties_handler_registry.iteritems():
 
660
            for key, value in handler(revision).items():
 
661
                self.to_file.write(indent + key + ': ' + value + '\n')
 
662
 
647
663
 
648
664
class LongLogFormatter(LogFormatter):
649
665
 
665
681
            to_file.write('\n')
666
682
            for parent_id in revision.rev.parent_ids:
667
683
                to_file.write(indent + 'parent: %s\n' % (parent_id,))
 
684
        self.show_properties(revision.rev, indent)
668
685
 
669
686
        author = revision.rev.properties.get('author', None)
670
687
        if author is not None:
878
895
                 end_revision=len(new_rh),
879
896
                 search=None)
880
897
 
 
898
 
 
899
properties_handler_registry = registry.Registry()