Mercurial > hg-stable
changeset 28937:3112c5e18835
hook: split config reading further
We want an easy way to fetch the hook config with and without honoring
"trusted" so that we can compare the values. So we extract the part
retrieving raw hook data from the config to be able to call it twice
in the next patch.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 14 Apr 2016 17:03:49 -0700 |
parents | 44bd37af54e5 |
children | ea1fec3e9aba |
files | mercurial/hook.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hook.py Thu Apr 14 02:28:46 2016 -0700 +++ b/mercurial/hook.py Thu Apr 14 17:03:49 2016 -0700 @@ -162,12 +162,18 @@ return r def _allhooks(ui): + """return a list of (hook-id, cmd) pairs sorted by priority""" + hooks = _hookitems(ui) + return [(k, v) for p, o, k, v in sorted(hooks.values())] + +def _hookitems(ui): + """return all hooks items ready to be sorted""" hooks = {} for name, cmd in ui.configitems('hooks'): if not name.startswith('priority'): priority = ui.configint('hooks', 'priority.%s' % name, 0) hooks[name] = (-priority, len(hooks), name, cmd) - return [(k, v) for p, o, k, v in sorted(hooks.values())] + return hooks _redirect = False def redirect(state):