I'm new to Mercurial and want to write some hooks to prevent merging between certain branches and the like. I'm looking for some kind of tutorial that goes through the whole loop.
I've looked at the API and these examples, but I still find it confusing. I've always been better at learning through a tutorial/workshop than by reading a man page or similar.
I can understand how the example code works, but how do I get Mercurial to recognize the functions?
e.g.) I've written this, but I don't understand how to make Mercurial run the code before a commit.
def is_bad_branch_name(ui, repo, **kwargs):
"""
Checks that a commit is always done on a named branch.
This function enforces Projectplace's branching convention.
@return: True if the branch name is invalid.
@returntype: Boolean
"""
branch = repo[None].branch()
branch_names = r'(TT|AZ)(-#)(\d)+(:)[\s\w]*'
acceptable_branch_names = re.compile(branch_names)
if not acceptable_branch_names.match(branch):
ui.warn('invalid branch name %r (use <TT|AZ>-#<number>: <description>)\n')
return True
return False