Keyword substitution removal into kwtemplater kwmap-templates
authorChristian Ebert <blacktrash@gmx.net>
Fri, 09 Feb 2007 13:47:11 +0100
branchkwmap-templates
changeset 133 cb60196a500b
parent 132 08a1f320c4d2
child 134 f869c65156f7
Keyword substitution removal into kwtemplater
hgkw/keyword.py
--- a/hgkw/keyword.py	Thu Feb 08 15:20:34 2007 +0100
+++ b/hgkw/keyword.py	Fri Feb 09 13:47:11 2007 +0100
@@ -115,6 +115,10 @@
         kwsub = templater.firstline(self.ui.popbuffer())
         return '$%s: %s $' % (kw, kwsub)
 
+    def shrink(self, text):
+        '''Returns text with all keyword substitutions removed.'''
+        return self.re_kw.sub(r'$\1$', text)
+
 
 def reposetup(ui, repo):
     '''Sets up repo, and filelog especially, as kwrepo and kwfilelog
@@ -206,14 +210,14 @@
         def add(self, text, meta, tr, link, p1=None, p2=None):
             '''Removes keyword substitutions when adding to filelog.'''
             if self.iskwcandidate(text):
-                text = self.kwt.re_kw.sub(r'$\1$', text)
+                text = self.kwt.shrink(text)
             return super(kwfilelog, self).add(text,
                             meta, tr, link, p1=p1, p2=p2)
 
         def cmp(self, node, text):
             '''Removes keyword substitutions for comparison.'''
             if self.iskwcandidate(text):
-                text = self.kwt.re_kw.sub(r'$\1$', text)
+                text = self.kwt.shrink(text)
             return super(kwfilelog, self).cmp(node, text)
 
     filelog.filelog = kwfilelog