我喜歡的單頭每如上所述科鉤;但是,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