您遇到过哪些有用的Mercurial钩子?
Mercurial书中有一些示例钩子:
我个人认为这些非常有用.我想看看:
请坚持使用bat和bash或Python的钩子.这样,*nix和Windows用户都可以使用它们.
Ry4*_*ase 16
我最喜欢的正式存储库钩子就是那个拒绝多个头的人.当你有一个需要合并后提示自动构建的持续集成系统时,这很棒.
这里有一些例子:MercurialWiki:TipsAndTricks - 防止产生多个头的推送
我使用Netbeans的这个版本:
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
#
# To forbid pushes which creates two or more headss
#
# [hooks]
# pretxnchangegroup.forbid_2heads = python:forbid2_head.forbid_2heads
from mercurial import ui
from mercurial.i18n import gettext as _
def forbid_2heads(ui, repo, hooktype, node, **kwargs):
if len(repo.heads()) > 1:
ui.warn(_('Trying to push more than one head, try run "hg merge" before it.\n'))
return True
Run Code Online (Sandbox Code Playgroud)
另一个好钩子是这个.它允许多个头,但只有它们在不同的分支中.
def hook(ui, repo, **kwargs):
for b in repo.branchtags():
if len(repo.branchheads(b)) > 1:
print "Two heads detected on branch '%s'" % b
print "Only one head per branch is allowed!"
return 1
return 0
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8962 次 |
| 最近记录: |