How can I setup a pre-commit hook , that will search for a string in the committed files and If found stop the commit ?
Ry4an's answer is almost correct :)
but you need to replace "hg export tip" with "hg diff".
tip is the last commited changeset, but are interested in local uncommited changes - so diff is what u need.
for my needs i added the following to my hgrc
precommit.removeDebug = hg diff -S | grep -v '^-' | (! egrep '(var_dump)|(exit)|(print_r)')
the -S includes subrepos (maye not need, and may be still buggy).
the grep -v '^-' removes lines from the diff that indicate lines that were removed.
i removed the -q so i at least have a idea what to remove, but unfortunatly this method cannot print you the file and linenumber of the occurence (as it is piped). maybe someone has a better way to do it.