简体   繁体   中英

Can I skip mercurial pre-commit hooks like in git?

I want to do something like git commit --no-verify but with mercurial. Are any ways to do it?

As noted in the hg help config documentation :

... Multiple hooks can be run for the same action by appending a suffix to the action. Overriding a site-wide hook can be done by changing its value or setting it to an empty string. Hooks can be prioritized by adding a prefix of "priority." to the hook name on a new line and setting the priority. The default priority is 0.

(emphasis mine). While this refers to "system-wide hooks", it works for in-repository hooks as well:

$ sed -n '/hooks/,+1p' .hg/hgrc
[hooks]
pre-commit = ./foo.sh
$ cat foo.sh
#! /bin/sh
echo foo
exit 1
$ hg commit
foo
abort: pre-commit hook exited with status 1

Obviously my pre-commit hook is working. Now to defeat it:

$ hg --config hooks.pre-commit= commit
nothing changed

(there was nothing to commit; overriding the pre-commit hook worked).

You will, of course, need to know which specific hook(s) you want to override, since there may be more than one pre-commit hook.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM