hook: small refactor to store hooks as dict instead of list
We are about to take untrusted hooks into account (to report them as failures)
so we need to rearrange the code a bit to allow config overwriting each other
in a later patch.
--- a/mercurial/hook.py Fri Apr 15 17:43:47 2016 +0000
+++ b/mercurial/hook.py Thu Apr 14 02:28:46 2016 -0700
@@ -162,12 +162,12 @@
return r
def _allhooks(ui):
- hooks = []
+ 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)]
+ hooks[name] = (-priority, len(hooks), name, cmd)
+ return [(k, v) for p, o, k, v in sorted(hooks.values())]
_redirect = False
def redirect(state):