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

前端 未结 5 625
生来不讨喜
生来不讨喜 2021-01-14 17:43

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

相关标签:
5条回答
  • 2021-01-14 18:01

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

    0 讨论(0)
  • 2021-01-14 18:06

    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.

    0 讨论(0)
  • 2021-01-14 18:07

    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

    0 讨论(0)
  • 2021-01-14 18:18

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

    Mercurial Hook: forbid multiple heads

    0 讨论(0)
  • 2021-01-14 18:21

    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.

    0 讨论(0)
提交回复
热议问题