I have some pretxncommit hooks in my local mercurial repository, those hooks are used to check that the commit message includes a reference to a ticket and some other sanity checks.
My problem is that when I try to use mercurial queues, commands like qnew try to run these hooks and the one of the ticket checking fails, I have seen the same problem with histedit and similar extensions.
Why are pretxncommit hooks executed with these commands? Do they run some kind of internal commit?
How can I make these hooks to be run only on commits?
Yes, a qnew creates a real commit and thus invokes all the relevant commit hooks. You can confirm this for yourself by temporarily disabling MQ while you have an MQ patch applied and looking at the log.
There is no way to make the pretxncommit hook apply to only some commands except by jury-rigging something with other hooks:
Here our pretxncommit hook makes sure a specific file doesn’t exist before running its (trivial) hook, and the pre-/post-qnew hooks create the file and clean it up.