# $Hg: hgkw/kwutil.py,v$
from mercurial.demandload import demandload
demandload(globals(), 'mercurial:util re')
def mkkw(repo, tip=False, node=''):
'''Gathers info for Hg keyword and returns it as raw replacement string.'''
# get hex
if tip:
p = repo.changelog.tip()
else:
p = repo.dirstate.parents()[0]
if not node:
node = repo.changectx(p)
user, date = repo.changelog.read(p)[1:3]
user = util.shortuser(user)
date = util.datestr(date=date, format=util.defaultdateformats[0])
# %Y-%m-%d %H:%M:%S
return r'\1 %s %s %s $' % (node, date, user)
def rekw():
'''Returns compiled regex to detect hg keywords.'''
return re.compile(r'([$]Hg: .+?,v).*?\$')