hook: split config reading further
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Thu, 14 Apr 2016 17:03:49 -0700
changeset 28937 3112c5e18835
parent 28936 44bd37af54e5
child 28938 ea1fec3e9aba
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.
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):