# HG changeset patch # User Christian Ebert # Date 1166518601 -3600 # Node ID 3a79665dcbc3f3698b0bedbadd091f109ea9a1c7 # Parent ebb39c6a1476eda131457b14d7e41d916c4643ac Make keyword do my hgkeyword; use basename again add() needs only str.replace(). TODO: Make even more compatible with cvs' $Id$? (date UTC, slashes) Check config before reading. And!: Use config file patterns, in cooperation with pretxnkw. This will expand keywords alread on commit! diff -r ebb39c6a1476 -r 3a79665dcbc3 hgkw/keyword.py --- a/hgkw/keyword.py Tue Dec 19 09:39:03 2006 +0100 +++ b/hgkw/keyword.py Tue Dec 19 09:56:41 2006 +0100 @@ -1,5 +1,5 @@ from mercurial import hg, filelog, revlog, context, util -import re +import os.path, re def reposetup(ui, repo): if not repo.local(): @@ -23,17 +23,18 @@ self._repo.ui.config("keywords", "expand", True)): c = context.filectx(self._repo, self._path, fileid=node, filelog=self) - def author(): return "$Author %s $" % c.user() - def date(): return "$Date %s $" % util.datestr(c.date()) - - data = re.sub(r'\$Author\$', author(), data) - data = re.sub(r'\$Date\$', date(), data) + hgkw = '$Hg: %s,v %s %s %s $' % ( + os.path.basename(c.path()), + c.changectx(), + util.datestr(date=c.date(), + format=util.defaultdateformats[0]), + util.shortuser(c.user())) + data = data.replace('$Hg$', hgkw) return data def add(self, text, meta, tr, link, p1=None, p2=None): if (not util.binary(text) and self._repo.ui.config("keywords", "remove", True)): - text = re.sub(r'\$Author[^\$]*\$', '$Author$', text) - text = re.sub(r'\$Date[^\$]*\$', '$Date$', text) + text = re.sub(r'\$Hg[^$]*?\$', '$Hg$', text) return super(kwfilelog, self).add(text, meta, tr, link, p1, p2) filelog.filelog = kwfilelog