We are using pretxncommit
hook for HG to run a quick static analysis check on code commited. However the hook is triggered on applying any changes to commit tree - which includes rebasing and using MQ to edit and squash commits.
Is it possible to somehow check what type of change is happening in hook itself? Like
def analyze_hook(ui, repo, node=None, **kwargs):
if repo.state.is_commit_added and not (repo.state.is_rebase or repo.state.is_patch):
return 0
from mercurial.cmdutil import _getrepostate
and check_getrepostate(repo) is not None
to check if the repo is currently in process of rebase or graft. It prevents hook from acting on merge conflicts, but it still acts once rebase or graft or MQ move is finished. – Borneol