用于预标签的Mercurial钩子

时间:2013-04-19 12:10:44

标签: mercurial

我想在将代码提交给mercurial时强制使用标记名称的策略(基于正则表达式)。经过大量搜索后,我找到了以下样本。

version_re = r'(ver-\d+\.\d+\.\d+|tip)$'
def invalidtag(ui, repo, hooktype, node, **kwargs):
assert(hooktype == 'pretag')

....


if not re_.match(tag):
    ui.warn('Invalid tag name "%s".\n' % tag)
    return True
return False

我的问题是,如何从正在提交的repo中获取标记名称。

1 个答案:

答案 0 :(得分:0)

根据this documentation,标签名称与钩子一起传入,所以我认为将钩子定义改为此可能有效:

def invalidtag(ui, repo, hooktype, node, tag, **kwargs):