私は上記のブランチごとのシングルヘッドフックが好きです。ただし、branchtags()は使用できなくなっbranchtags()
たため、に置き換える必要があります。branchmap()
(コメントできなかったので、ここに貼り付けました)。
また、 https: //bobhood.wordpress.com/2012/12/14/branch-freezing-with-mercurial/のFrozenBranchesのフックも気に入っています。次のように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など)を更新しようとすると、トランザクションは中止されます。