--- a/hgkw/keyword.py Sun Feb 11 19:51:22 2007 +0100
+++ b/hgkw/keyword.py Mon Feb 12 00:38:47 2007 +0100
@@ -100,7 +100,7 @@
class kwtemplater(object):
'''
Sets up keyword templates, corresponding keyword regex, and
- provides keyword expansion function.
+ provides keyword substitution functions.
'''
def __init__(self, ui, repo):
self.ui = ui
@@ -132,11 +132,13 @@
keywordsub = templater.firstline(self.ui.popbuffer())
return '$%s: %s $' % (kw, keywordsub)
- def expand(self, path, node, data):
+ def expand(self, path, node, filelog, data):
'''Returns data with expanded keywords.'''
if util.binary(data):
return data
- return self.re_kw.sub(lambda m: self.kwsub(m, path, node), data)
+ c = context.filectx(self.repo, path, fileid=node, filelog=filelog)
+ cnode = c.node()
+ return self.re_kw.sub(lambda m: self.kwsub(m, path, cnode), data)
def shrink(self, text):
'''Returns text with all keyword substitutions removed.'''
@@ -227,9 +229,7 @@
'''Substitutes keywords when reading filelog.'''
data = super(kwfilelog, self).read(node)
if self.kwt:
- c = context.filectx(self._repo, self._path,
- fileid=node, filelog=self)
- data = self.kwt.expand(self._path, c.node(), data)
+ data = self.kwt.expand(self._path, node, self, data)
return data
def add(self, text, meta, tr, link, p1=None, p2=None):