/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Guillermo Gonzalez
  • Date: 2008-03-04 14:05:15 UTC
  • mto: (3542.1.1 logdisplayers)
  • mto: This revision was merged to the branch mainline in revision 3556.
  • Revision ID: guillo.gonzo@gmail.com-20080304140515-hzph38f78xo6obgr
 * cleanup a bit the interface
 * added blackbox test and docstring to the methods

Show diffs side-by-side

added added

removed removed

Lines of Context:
603
603
    Plugins can register functions to show custom revision properties using
604
604
    the class method add_show_properties(function). The registered function
605
605
    must respect the following interface description:
606
 
        def my_show_properties(to_file, properties_dict):
607
 
            # code that use to_file.write() to send the correct output
 
606
        def my_show_properties(properties_dict):
 
607
            # code that returns a dict {'name':'value'} of the properties 
 
608
            # to be shown
608
609
    """
609
610
    registered_show_properties = []
610
611
 
640
641
        return address
641
642
 
642
643
    @classmethod
643
 
    def add_show_properties(child=None, func=None):
644
 
        if not func is None:
645
 
            LogFormatter.registered_show_properties.append(func)
 
644
    def add_show_properties(child=None, function=None):
 
645
        """add a properties handler to the list
 
646
            * child: the derived class object
 
647
            * function: a funtion that handle revision properties"""
 
648
        if not function is None:
 
649
            LogFormatter.registered_show_properties.append(function)
646
650
 
647
651
    def show_properties(self, properties):
 
652
        """shows the custom properties returned by each 
 
653
            function in registered_show_properties."""
648
654
        filtered_props = properties.copy()
649
655
        if filtered_props.has_key('branch-nick'): 
650
 
            filtered_props.__delitem__('branch-nick')
 
656
            del filtered_props['branch-nick']
651
657
        for func in LogFormatter.registered_show_properties:
652
 
            func(self.to_file, filtered_props)
653
 
 
 
658
            for key, value in func(filtered_props).items():
 
659
                self.to_file.write(key + ': ' + value + '\n')
654
660
 
655
661
class LongLogFormatter(LogFormatter):
656
662
 
684
690
            for parent_id in revision.rev.parent_ids:
685
691
                to_file.write(indent + 'parent: %s\n' % (parent_id,))
686
692
        
 
693
        # show custom properties
687
694
        self.show_properties(revision.rev.properties)
688
695
 
689
696
        author = revision.rev.properties.get('author', None)