~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Erik Bagfors
  • Date: 2007-04-05 09:51:17 UTC
  • mfrom: (2401 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2439.
  • Revision ID: erik@bagfors.nu-20070405095117-ndglm72iuaxpi6u8
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
                           NotBranchError, UninitializableFormat,
55
55
                           UnlistableStore, UnlistableBranch,
56
56
                           )
 
57
from bzrlib.hooks import Hooks
57
58
from bzrlib.symbol_versioning import (deprecated_function,
58
59
                                      deprecated_method,
59
60
                                      DEPRECATED_PARAMETER,
892
893
            control_files.unlock()
893
894
 
894
895
 
895
 
class BranchHooks(dict):
 
896
class BranchHooks(Hooks):
896
897
    """A dictionary mapping hook name to a list of callables for branch hooks.
897
898
    
898
899
    e.g. ['set_rh'] Is the list of items to be called when the
905
906
        These are all empty initially, because by default nothing should get
906
907
        notified.
907
908
        """
908
 
        dict.__init__(self)
 
909
        Hooks.__init__(self)
909
910
        # Introduced in 0.15:
910
911
        # invoked whenever the revision history has been set
911
912
        # with set_revision_history. The api signature is
944
945
        # and an empty branch recieves new_revno of 0, new_revid of None.
945
946
        self['post_uncommit'] = []
946
947
 
947
 
    def install_hook(self, hook_name, a_callable):
948
 
        """Install a_callable in to the hook hook_name.
949
 
 
950
 
        :param hook_name: A hook name. See the __init__ method of BranchHooks
951
 
            for the complete list of hooks.
952
 
        :param a_callable: The callable to be invoked when the hook triggers.
953
 
            The exact signature will depend on the hook - see the __init__ 
954
 
            method of BranchHooks for details on each hook.
955
 
        """
956
 
        try:
957
 
            self[hook_name].append(a_callable)
958
 
        except KeyError:
959
 
            raise errors.UnknownHook('branch', hook_name)
960
 
 
961
948
 
962
949
# install the default hooks into the Branch class.
963
950
Branch.hooks = BranchHooks()