Stricter regex; regroup kwtemplater init code
authorChristian Ebert <blacktrash@gmx.net>
Thu, 26 Jul 2007 18:24:35 +0200
changeset 216 f35a0c382168
parent 215 ff719fcc10a3
child 217 e55e3f6c6608
Stricter regex; regroup kwtemplater init code
hgkw/keyword.py
--- a/hgkw/keyword.py	Tue Jul 24 15:13:16 2007 +0200
+++ b/hgkw/keyword.py	Thu Jul 26 18:24:35 2007 +0200
@@ -127,9 +127,6 @@
                 templates[k] = templater.parsestring(templates[k],
                                                      quoted=False)
         self.templates = templates or self.deftemplates
-        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:
@@ -139,6 +136,9 @@
                 # 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.'''