How can I create a mercury hook that prevents new heads from appearing?

I have several repositories that have been converted from SVN and moving forward, we want to make sure that when people click on the repository, they cannot create additional chapters. there are several hooks on the TipsAndTricks wiki page, which prevents clicking if there are several heads, but how can I build a hook that prevents new heads from clicking?

It seems that the correct way to do this is to compare the number of goals from revision 0: parent, and then compare 0: hint, but I can not find a way to do this. hg heads -r $HG_NODE shows me only the number of heads after the user made the first press.

+3
source share
5 answers

Use hg ci -m 'Closed branch feature-x' --close-branch to close everything but one head, and then use a regular single-head hook.

0
source

By default, hg push prevents extra heads from being pressed by requiring the -f flag. You can write the Mercurial extension so that it ignores this flag, effectively disabling the click of new heads.

However, I would challenge the wisdom of mechanically banning new heads. Instead, I would train your team to merge properly before pushing, while letting them do it in the rare case that it makes sense, especially since Mercurial is already warning you.

+5
source

Mercurial wiki - Tips & Tricks - Preventing clicks that would create multiple heads

Indicates several existing hooks that may be useful for copying and adapting.

+3
source

Check out this link. It automates the process of providing multiple heads

Mercurial Hook: Prohibit Multiple Heads

+1
source

All Articles