check_hook fails when used with precommit hook
check_hook takes 4 input parameters while fixup_hook takes 3. This means that while fixup_hook can be used as a precommit hook, check_hook cannot (under hg 2.2.3 at least). The documentation seems to imply that check_hook can be used as a precommit hook as well.
As a workaround, I have modified checkfiles.py to provide a new hook precommit_check_hook where I use it. The hook is very simple, so I presume it could be incorporated into the check_hook method, possibly by providing a default value for node. My workaround hook:
def precommit_check_hook(ui, repo, hooktype, **kwargs): '''Blocks commits containing tabs and/or trailing whitespace from modified files in the working directory'''
ui.note('checkfiles: checking for tabs and/or trailing whitespace in changed files...\n') cf = CheckFiles(ui, repo, repo[None]) return cf.check()