--- a/hgkw/keyword.py Mon Jan 15 19:41:18 2007 +0100
+++ b/hgkw/keyword.py Mon Jan 15 20:18:43 2007 +0100
@@ -84,10 +84,9 @@
Sets up keyword templates, corresponding keyword regex, and
provides keyword expansion function.
'''
- def __init__(self, ui, repo, node=None):
+ def __init__(self, ui, repo):
self.ui = ui
self.repo = repo
- self.node = node
templates = {}
for k, v in self.ui.configitems('keywordmaps'):
templates[k] = v
@@ -97,15 +96,12 @@
self.t = cmdutil.changeset_templater(self.ui, self.repo,
False, '', False)
- def expand(self, mobj, path, node=None):
- self.node = self.node or node
+ def expand(self, mobj, path, node):
kw = mobj.group(1)
template = templater.parsestring(self.templates[kw], quoted=False)
self.t.use_template(template)
self.ui.pushbuffer()
- self.t.show(changenode=self.node,
- changes=self.repo.changelog.read(self.node),
- root=self.repo.root, file=path)
+ self.t.show(changenode=node, root=self.repo.root, file=path)
return '$%s: %s $' % (kw, self.ui.popbuffer())
@@ -144,7 +140,7 @@
c = context.filectx(self._repo, self._path,
fileid=node, filelog=self)
return self.kwt.re_kw.sub(lambda m:
- self.kwt.expand(m, self._path, node=c.node()), data)
+ self.kwt.expand(m, self._path, c.node()), data)
return data
def add(self, text, meta, tr, link, p1=None, p2=None):
@@ -197,11 +193,12 @@
if not candidates:
return
- kwt = kwtemplater(ui, repo, node=bin(args['node']))
+ kwt = kwtemplater(ui, repo)
+ node = bin(args['node'])
for f in candidates:
data = repo.wfile(f).read()
if not util.binary(data):
- data, kwct = kwt.re_kw.subn(lambda m: kwt.expand(m, f), data)
+ data, kwct = kwt.re_kw.subn(lambda m: kwt.expand(m, f, node), data)
if kwct:
ui.debug(_('overwriting %s expanding keywords\n' % f))
repo.wfile(f, 'w').write(data)