hook: don't crash on syntax errors in python hooks
We had some real-world cases where syntax errors in Python hooks would crash
the whole process and leave it in an indeterminate state. Handle those better.
$ echo "[extensions]" >> $HGRCPATH
$ echo "mq=" >> $HGRCPATH
$ hg init
$ echo 'base' > base
$ hg ci -Ambase
adding base
$ hg qnew -mmqbase mqbase
$ hg qsave
$ hg qrestore 2
restoring status: hg patches saved state