diff -r 44bd37af54e5 -r 3112c5e18835 mercurial/hook.py --- 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):