hgkw/keyword.py
branchkwmap-templates
changeset 133 cb60196a500b
parent 129 15e8cd7f5295
child 134 f869c65156f7
--- 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