[PATCH 2 of 3] hook: split config reading further
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Apr 15 03:50:21 EDT 2016
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1460678629 25200
# Thu Apr 14 17:03:49 2016 -0700
# Node ID 41e1d17cdc4943805d5e7a6e7c131367eb94e8d3
# Parent 063993ec1c63c22ff616609001b50292668bd92e
# EXP-Topic hooks
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 extra the part retriving raw
hook data from the config to be able to call it twice in the next patch.
diff -r 063993ec1c63 -r 41e1d17cdc49 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,13 +162,19 @@
return r
def _allhooks(ui):
+ """return a list of (hook-id, cmd) pair sorted by priority"""
+ hooks = _hookitems(ui)
+ order = sorted(hooks, key=lambda x: hooks[x][:2] + (x,))
+ return [(k, hooks[k][2]) for k in order]
+
+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), cmd)
- order = sorted(hooks, key=lambda x: hooks[x][:2] + (x,))
- return [(k, hooks[k][2]) for k in order]
+ return hooks
_redirect = False
def redirect(state):
More information about the Mercurial-devel
mailing list