Make keyword.py depend on resurrected kwutil.py
This makes pretxnkw perhaps a bit slower, but is more readable.
'''
kwutil provides required little helpers for the Mercurial
keyword extension and the Python pretxncommit hook pretxnkw.
'''
from mercurial import util
import os.path
# supported keywords for use in regexes
hgkeywords = 'Id|Header|Author|Date|Revision|RCSFile|Source'
def kwexpand(matchobj, repo, Revision, f, date, Author):
'''Called by keyword extension and pretxnkw pretxncomit hook,
sets supported keywords as local variables and evaluates them
to their expansion if matchobj is equal to their string
representation.'''
RCSFile = os.path.basename(f)+',v'
Source = os.path.join(repo.root, f)+',v'
Date = util.datestr(date)
revdateauth = '%s %s %s' % (Revision,
util.datestr(date=date, format=util.defaultdateformats[0]),
# %Y-%m-%d %H:%M:%S
util.shortuser(Author))
Header = '%s %s' % (Source, revdateauth)
Id = '%s %s' % (RCSFile, revdateauth)
return '$%s: %s $' % (matchobj.group(1), eval(matchobj.group(1)))