--- a/hgkw/keyword.py Fri Feb 09 16:13:51 2007 +0100
+++ b/hgkw/keyword.py Fri Feb 09 16:16:22 2007 +0100
@@ -105,7 +105,13 @@
def __init__(self, ui, repo):
self.ui = ui
self.repo = repo
- self.templates = dict(ui.configitems('keywordmaps')) or deftemplates
+ templates = dict(ui.configitems('keywordmaps'))
+ if templates:
+ # parse templates here for less overhead in kwsub matchfunc
+ for k in templates.keys():
+ templates[k] = templater.parsestring(templates[k],
+ quoted=False)
+ self.templates = templates or deftemplates
self.re_kw = re.compile(r'\$(%s)[^$]*?\$' %
'|'.join(re.escape(k) for k in self.templates.keys()))
templater.common_filters['utcdate'] = utcdate
@@ -120,8 +126,7 @@
def kwsub(self, mobj, path, node):
'''Substitutes keyword using corresponding template.'''
kw = mobj.group(1)
- template = templater.parsestring(self.templates[kw], quoted=False)
- self.t.use_template(template)
+ self.t.use_template(self.templates[kw])
self.ui.pushbuffer()
self.t.show(changenode=node, root=self.repo.root, file=path)
keywordsub = templater.firstline(self.ui.popbuffer())