--- a/hgkw/keyword.py Fri Dec 29 15:36:50 2006 +0100
+++ b/hgkw/keyword.py Fri Dec 29 16:34:01 2006 +0100
@@ -43,8 +43,10 @@
from mercurial import cmdutil, commands, context, filelog, revlog, util
import os.path, re, sys
-# supported keywords for use in regexes
-hgkeywords = 'Id|Header|Author|Date|Revision|RCSFile|Source'
+
+re_kw = re.compile(
+ r'\$(Id|Header|Author|Date|Revision|RCSFile|Source)[^$]*?\$')
+
def kwexpand(matchobj, repo, path, changeid=None, fileid=None, filelog=None):
'''Called by kwfilelog.read and pretxnkw.
@@ -94,7 +96,6 @@
mf = util.matcher(self._repo.root,
'', [pat], [], [])[1]
if mf(self._path):
- re_kw = re.compile(r'\$(%s)\$' % hgkeywords)
return re_kw.sub(lambda m:
kwexpand(m, self._repo, self._path,
fileid=node, filelog=self),
@@ -103,7 +104,6 @@
def add(self, text, meta, tr, link, p1=None, p2=None):
if not util.binary(text):
- re_kw = re.compile(r'\$(%s): [^$]+? \$' % hgkeywords)
text = re_kw.sub(r'$\1$', text)
return super(kwfilelog, self).add(text, meta, tr, link, p1, p2)
@@ -155,9 +155,6 @@
if not files:
return False
- # update both expanded and unexpanded keywords
- re_kw = re.compile(r'\$(%s)(: [^$]+? )?\$' % hgkeywords)
-
for f in files:
data = repo.wfile(f).read()
if not util.binary(data):