How can I create a mercurial hook that prevents new heads?

跟風遠走 提交于 2019-12-01 09:18:22

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.

alexandrul

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.

Check this link. It automates the process of allowing multiple heads

Mercurial Hook: forbid multiple heads

Use hg ci -m 'Closed branch feature-x' --close-branch to close all but one head and then apply a normal single-head hook.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!