Mercurial > hg
comparison mercurial/hook.py @ 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 |
comparison
equal
deleted
inserted
replaced
28936:44bd37af54e5 | 28937:3112c5e18835 |
---|---|
160 raise error.HookAbort(_('%s hook %s') % (name, desc)) | 160 raise error.HookAbort(_('%s hook %s') % (name, desc)) |
161 ui.warn(_('warning: %s hook %s\n') % (name, desc)) | 161 ui.warn(_('warning: %s hook %s\n') % (name, desc)) |
162 return r | 162 return r |
163 | 163 |
164 def _allhooks(ui): | 164 def _allhooks(ui): |
165 """return a list of (hook-id, cmd) pairs sorted by priority""" | |
166 hooks = _hookitems(ui) | |
167 return [(k, v) for p, o, k, v in sorted(hooks.values())] | |
168 | |
169 def _hookitems(ui): | |
170 """return all hooks items ready to be sorted""" | |
165 hooks = {} | 171 hooks = {} |
166 for name, cmd in ui.configitems('hooks'): | 172 for name, cmd in ui.configitems('hooks'): |
167 if not name.startswith('priority'): | 173 if not name.startswith('priority'): |
168 priority = ui.configint('hooks', 'priority.%s' % name, 0) | 174 priority = ui.configint('hooks', 'priority.%s' % name, 0) |
169 hooks[name] = (-priority, len(hooks), name, cmd) | 175 hooks[name] = (-priority, len(hooks), name, cmd) |
170 return [(k, v) for p, o, k, v in sorted(hooks.values())] | 176 return hooks |
171 | 177 |
172 _redirect = False | 178 _redirect = False |
173 def redirect(state): | 179 def redirect(state): |
174 global _redirect | 180 global _redirect |
175 _redirect = state | 181 _redirect = state |