--- a/hgkw/keyword.py Thu Aug 09 09:49:38 2007 +0200
+++ b/hgkw/keyword.py Thu Aug 09 14:20:03 2007 +0200
@@ -104,7 +104,7 @@
Sets up keyword templates, corresponding keyword regex, and
provides keyword substitution functions.
'''
- deftemplates = {
+ templates = {
'Revision': '{node|short}',
'Author': '{author|user}',
'Date': '{date|utcdate}',
@@ -121,12 +121,15 @@
self.path = path
self.node = node
- templates = dict(ui.configitems('keywordmaps'))
- if templates:
- for k in templates.keys():
- templates[k] = templater.parsestring(templates[k],
- quoted=False)
- self.templates = templates or self.deftemplates
+ kwmaps = self.ui.configitems('keywordmaps')
+ if kwmaps:
+ self.templates = {}
+ for k, v in kwmaps:
+ self.templates[k] = templater.parsestring(v, quoted=False)
+ escaped = [re.escape(k) for k in self.templates.keys()]
+ rawkeyword = r'\$(%s)(: [^$\n\r]*? )??\$'
+ self.re_kw = re.compile(rawkeyword % '|'.join(escaped))
+
if self.t:
templater.common_filters['utcdate'] = utcdate
try:
@@ -136,9 +139,6 @@
# depending on hg rev changeset_templater has extra "brinfo" arg
self.t = cmdutil.changeset_templater(self.ui, self.repo,
False, None, '', False)
- escaped = [re.escape(k) for k in self.templates.keys()]
- rawkeyword = r'\$(%s)(: [^$\n\r]*? )??\$'
- self.re_kw = re.compile(rawkeyword % '|'.join(escaped))
def _ctxnode(self, node):
'''Obtains missing node from file context.'''
@@ -338,7 +338,7 @@
ui.readconfig(opts['rcfile'])
if opts['default']:
kwstatus = 'default'
- kwmaps = kwtemplater.deftemplates
+ kwmaps = kwtemplater.templates
if ui.configitems('keywordmaps'):
# override maps from optional rcfile
for k, v in kwmaps.items():
@@ -351,8 +351,7 @@
fp.close()
ui.readconfig(repo.join('hgrc'))
if not opts['default']:
- kwmaps = (dict(ui.configitems('keywordmaps')) or
- kwtemplater.deftemplates)
+ kwmaps = dict(ui.configitems('keywordmaps')) or kwtemplater.templates
reposetup(ui, repo)
for k, v in ui.configitems('extensions'):
if k.endswith('keyword'):