mercurial/hook.py
changeset 15896 30c34fde40cc
parent 15512 8b011ededfb2
child 17048 15d4d475de9e
--- a/mercurial/hook.py	Sun Jan 15 18:00:01 2012 -0600
+++ b/mercurial/hook.py	Sun Jan 15 13:50:12 2012 -0700
@@ -124,6 +124,14 @@
         ui.warn(_('warning: %s hook %s\n') % (name, desc))
     return r
 
+def _allhooks(ui):
+    hooks = []
+    for name, cmd in ui.configitems('hooks'):
+        if not name.startswith('priority'):
+            priority = ui.configint('hooks', 'priority.%s' % name, 0)
+            hooks.append((-priority, len(hooks), name, cmd))
+    return [(k, v) for p, o, k, v in sorted(hooks)]
+
 _redirect = False
 def redirect(state):
     global _redirect
@@ -147,7 +155,7 @@
             pass
 
     try:
-        for hname, cmd in ui.configitems('hooks'):
+        for hname, cmd in _allhooks(ui):
             if hname.split('.')[0] != name or not cmd:
                 continue
             if util.safehasattr(cmd, '__call__'):