Mercurial > public > mercurial-scm > hg
comparison mercurial/hook.py @ 34687:e79b6300d97c
hook: add a 'hashook' function to test for hook existence
Preparing the data for some hooks can be expensive. Add a function to check if
a hook exists so we can skip useless preparation if no hook is configured.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Sun, 08 Oct 2017 13:08:31 +0200 |
parents | 799db2af824c |
children | 056a9c8813aa |
comparison
equal
deleted
inserted
replaced
34686:0d1b8be8d8a8 | 34687:e79b6300d97c |
---|---|
187 _redirect = False | 187 _redirect = False |
188 def redirect(state): | 188 def redirect(state): |
189 global _redirect | 189 global _redirect |
190 _redirect = state | 190 _redirect = state |
191 | 191 |
192 def hashook(ui, htype): | |
193 """return True if a hook is configured for 'htype'""" | |
194 if not ui.callhooks: | |
195 return False | |
196 for hname, cmd in _allhooks(ui): | |
197 if hname.split('.')[0] == htype and cmd: | |
198 return True | |
199 return False | |
200 | |
192 def hook(ui, repo, htype, throw=False, **args): | 201 def hook(ui, repo, htype, throw=False, **args): |
193 if not ui.callhooks: | 202 if not ui.callhooks: |
194 return False | 203 return False |
195 | 204 |
196 hooks = [] | 205 hooks = [] |