Mercurial > hg
changeset 28936:44bd37af54e5
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.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 14 Apr 2016 02:28:46 -0700 |
parents | a4c5c23de1d3 |
children | 3112c5e18835 |
files | mercurial/hook.py |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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):