我寫的(進程)掛鉤,以防止添加本地BAD標籤名稱:水銀鉤上設置標籤名稱政策
.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
如何使這個支票pretxnchangegroup鉤?
我嘗試寫這樣的代碼:
def pushbadtag(ui, repo, hooktype, node, **kwargs): assert(hooktype == 'pretxnchangegroup') re_ = re.compile(goodtag_re) for rev in xrange(repo[node].rev(), len(repo)): ui.warn('rev: %d\n' % rev) for tag in repo[rev].tags(): ui.warn('tag: ' + tag + '\n') if not re_.match(tag): ui.warn('Invalid tag name "%s" for rev: "%s".\n' % (tag, rev)) ui.warn('Use one of tip, ver-xx.xx.xx\n') return True return False
但是當我(推回購與上pretxnchangegroup鉤啓用:
$ hg tag gg $ hg push -f pushing to /cygdrive/d/home/tmp/hg/good searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) rev: 35 tag: tip
你可以看到,rev.tags()不返回gg標記!