~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

Merge from bzr.dev, resolving conflicts.

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,
924
925
            control_files.unlock()
925
926
 
926
927
 
927
 
class BranchHooks(dict):
 
928
class BranchHooks(Hooks):
928
929
    """A dictionary mapping hook name to a list of callables for branch hooks.
929
930
    
930
931
    e.g. ['set_rh'] Is the list of items to be called when the
937
938
        These are all empty initially, because by default nothing should get
938
939
        notified.
939
940
        """
940
 
        dict.__init__(self)
 
941
        Hooks.__init__(self)
941
942
        # Introduced in 0.15:
942
943
        # invoked whenever the revision history has been set
943
944
        # with set_revision_history. The api signature is
976
977
        # and an empty branch recieves new_revno of 0, new_revid of None.
977
978
        self['post_uncommit'] = []
978
979
 
979
 
    def install_hook(self, hook_name, a_callable):
980
 
        """Install a_callable in to the hook hook_name.
981
 
 
982
 
        :param hook_name: A hook name. See the __init__ method of BranchHooks
983
 
            for the complete list of hooks.
984
 
        :param a_callable: The callable to be invoked when the hook triggers.
985
 
            The exact signature will depend on the hook - see the __init__ 
986
 
            method of BranchHooks for details on each hook.
987
 
        """
988
 
        try:
989
 
            self[hook_name].append(a_callable)
990
 
        except KeyError:
991
 
            raise errors.UnknownHook('branch', hook_name)
992
 
 
993
980
 
994
981
# install the default hooks into the Branch class.
995
982
Branch.hooks = BranchHooks()