diff -r d34486cc99b0 -r 682e684a15e9 hgkw/keyword.py --- a/hgkw/keyword.py Sun Jan 14 12:39:23 2007 +0100 +++ b/hgkw/keyword.py Sun Jan 14 14:00:45 2007 +0100 @@ -39,11 +39,6 @@ re_kw = re.compile( r'\$(Id|Header|Author|Date|Revision|RCSFile|Source)[^$]*?\$') -def kwexpand(mobj, kwfctx): - '''Called by kwfilelog.read and pretxnkw. - Expands keywords according to file context.''' - return '$%s: %s $' % (mobj.group(1), kwfctx.expand(mobj.group(1))) - def kwfmatches(ui, repo, files): '''Selects candidates for keyword substitution configured in keyword section in hgrc.''' @@ -87,9 +82,10 @@ def Id(self): return ' '.join( [self.RCSFile(), self.Revision(), self.Date(), self.Author()]) - def expand(self, kw): + def expand(self, mobj): '''Called from kwexpand, evaluates keyword.''' - return eval('self.%s()' % kw) + kw = mobj.group(1) + return '$%s: %s $' % (kw, eval('self.%s()' % kw)) def reposetup(ui, repo): @@ -126,7 +122,7 @@ if self.iskwcandidate(data): kwfctx = kwfilectx(self._repo, self._path, fileid=node, filelog=self) - return re_kw.sub(lambda m: kwexpand(m, kwfctx), data) + return re_kw.sub(kwfctx.expand, data) return data def add(self, text, meta, tr, link, p1=None, p2=None): @@ -183,7 +179,7 @@ data = repo.wfile(f).read() if not util.binary(data): kwfctx = kwfilectx(repo, f, changeid=args['node']) - data, kwct = re_kw.subn(lambda m: kwexpand(m, kwfctx), data) + data, kwct = re_kw.subn(kwfctx.expand, data) if kwct: ui.debug(_('overwriting %s expanding keywords\n' % f)) repo.wfile(f, 'w').write(data)