Last Updated: February 25, 2016
·
1.806K
· fmariluis

Adding a pre-commit hook to Mercurial

Let's suppose you want to avoid committing an accidental:

import pdb; pdb.set_trace()

You can do that if you include this in your .hgrc:

[hooks]
pretxncommit.pdb = hg export tip | (! grep -E -q 'pdb')

Replace with the expression or regex you need and that's it, whenever you try to commit something that matches it'll fail with the pretxncommit.pdb message.