Is there a tag rule engine in Mercurial? I want to enforce the tag name. For example. tag VERSION 2.4...I want to have a way to enforce "VERSION" to be in the tag name no mater what?
Thanks.
You have the pretag
hook on which you could add some validation. You have some information on this thread:
Mercurial hook to set policy on tag names
.hg/hgrc:
pretag.badtagname = python:.hg/hgcheck.py:localbadtag
.hg/hgcheck.py:
goodtag_re = r'(ver-\d+\.\d+\.\d+|tip)$' def localbadtag(ui, repo, hooktype, node, **kwargs): assert(hooktype == 'pretag') re_ = re.compile(goodtag_re) if not re_.match(tag): ui.warn('Invalid tag name "%s".\n' % tag) ui.warn('Use one of tip, ver-xx.xx.xx\n') return True return False
You have some hook examples over here: https://www.mercurial-scm.org/wiki/HookExamples
You can also consider enforcing these rules inside your release management process, ie provide build scripts where version is taken as input, validated, and VERSION is then prepended to the final tag name. It would not restrict people from tagging directly with an invalid name, but normally an automated release/build process saves so much time and error that no one wants to go back to a manual process.
Ideally this is all centralized on your CI server so you don't rely on custom hooks which needs to be installed in each Mercurial installation.