I'm running the central mercurial repository, and I understand that the normal "push" command will stop if the remote user is trying to force multiple "head"s to my central repository. The intention is that the remote user should first pull and merge before trying to push again.
However, using hg push --force will override this. I would like to block this behavior.
I am currently using the hgwebdir.cgi plus some apache-auth stuff to limit users ability to pull and push.
EDIT: a pretxnchangegroup hook solved the problem. Hook worked:
#!/bin/bash
# force-one-head
# add the following to <repository>/.hg/hgrc :
# [hooks]
# pretxnchangegroup.forceonehead = /path/to/force-one-head
if [[ `hg heads -q | wc -l` -gt 1 ]]; then
echo "There are multiple heads."
echo "Please 'hg pull' and get your repository up to date first."
echo "Also, don't 'hg push --force' because that won't work either."
exit 1
fi
hg push, then Mercurial will abort before anything is pushed and your script is not executed. If they dohg push --force, then your script is executed but so the line is redundant. – Martin Geisler Dec 18 '11 at 10:52