# HG changeset patch # User Christian Ebert # Date 1171025231 -3600 # Node ID cb60196a500b13d2581a4dd7c4347b471fc04146 # Parent 08a1f320c4d269267f0480075f3c25ba8de0ee72 Keyword substitution removal into kwtemplater diff -r 08a1f320c4d2 -r cb60196a500b 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