I have several repositories that have been converted from SVN and moving forward we want make sure when people push to the repository they can\'t create additional heads. th
Use hg ci -m 'Closed branch feature-x' --close-branch
to close all but one head and then apply a normal single-head hook.
By default, hg push
prevents pushing of additional heads, requiring the -f
flag. You could write a Mercurial extension to make it ignore that flag, effectively disabling pushing of new heads.
That said, I would question the wisdom of mechanically disallowing new heads. Instead, I would train your team to merge properly before pushing, while still allowing them to do it on the rare occasion that it makes sense, especially since Mercurial already warns you.
This is the best: https://www.mercurial-scm.org/wiki/TipsAndTricks#Prevent_a_push_that_would_create_multiple_heads
I personally use: http://hg.python.org/hooks/file/default/checkheads.py
Check this link. It automates the process of allowing multiple heads
Mercurial Hook: forbid multiple heads
Mercurial wiki - Tips and Tricks - Prevent a push that would create multiple heads
Points to several existing hooks which may be useful to copy and adapt.