我喜欢的单头每如上所述科钩;但是,branchtags()
应替换为branchmap()
,因为branchtags()不再可用。 (我不能评论那个,所以我坚持下来)。
我也喜欢https://bobhood.wordpress.com/2012/12/14/branch-freezing-with-mercurial/的冻结分支。你在你的hgrc添加一个部分是这样的:
[frozen_branches]
freeze_list = BranchFoo, BranchBar
,并添加了钩:
def frozenbranches(ui, repo, **kwargs):
hooktype = kwargs['hooktype']
if hooktype != 'pretxnchangegroup':
ui.warn('frozenbranches: Only "pretxnchangegroup" hooks are supported by this hook\n')
return True
frozen_list = ui.configlist('frozen_branches', 'freeze_list')
if frozen_list is None:
# no frozen branches listed; allow all changes
return False
try:
ctx = repo[kwargs['node']]
start = ctx.rev()
end = len(repo)
for rev in xrange(start, end):
node = repo[rev]
branch = node.branch()
if branch in frozen_list:
ui.warn("abort: %d:%s includes modifications to frozen branch: '%s'!\n" % (rev, node.hex()[:12], branch))
# reject the entire changegroup
return True
except:
e = sys.exc_info()[0]
ui.warn("\nERROR !!!\n%s" % e)
return True
# allow the changegroup
return False
如果有人试图更新冻结分支机构(例如,BranchFoo,BranchBar)的交易将被中止。
也许更多的想法可以从这些Subversion问题中收集:http://stackoverflow.com/questions/6155/common-types-of-subversion-hooks和http://stackoverflow.com/questions/884608/share- common-useful-svn-pre-commit-hooks ... – Macke 2010-12-29 10:11:54