# HG changeset patch # User Pierre-Yves David # Date 1460626126 25200 # Node ID 44bd37af54e57b7968ed3713a2c03b20c6a587de # Parent a4c5c23de1d38dd85db4413f15d2e89acaf5719e 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. diff -r a4c5c23de1d3 -r 44bd37af54e5 mercurial/hook.py --- 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):