--- a/hgkw/keyword.py Thu Dec 28 18:14:59 2006 +0100
+++ b/hgkw/keyword.py Thu Dec 28 18:41:54 2006 +0100
@@ -81,28 +81,30 @@
def read(self, node):
data = super(kwfilelog, self).read(node)
- if util.binary(data):
- return data
+ if not self._path.startswith('.hg') and not util.binary(data):
- c = context.filectx(self._repo, self._path, fileid=node,
- filelog=self)
- if self._path.startswith('.hg'):
- return data
+ c = context.filectx(self._repo, self._path, fileid=node,
+ filelog=self)
+ for pat, opt in self._repo.ui.configitems('keyword'):
+ if opt == 'expand':
+ mf = util.matcher(self._repo.root,
+ '', [pat], [], [])[1]
+ if mf(self._path):
- for pat, opt in self._repo.ui.configitems('keyword'):
- if opt == 'expand':
- mf = util.matcher(self._repo.root,
- '', [pat], [], [])[1]
- if mf(self._path):
+ def kwexpander(matchobj):
+ return kwexpand(matchobj,
+ self._repo, c.changectx(), self._path,
+ c.date(), c.user())
- def kwexpander(matchobj):
- return kwexpand(matchobj,
- self._repo, c.changectx(), self._path,
- c.date(), c.user())
+ re_kw = re.compile(r'\$(%s)\$' % hgkeywords)
+ return re_kw.sub(kwexpander, data)
+ return data
- re_kw = re.compile(r'\$(%s)\$' % hgkeywords)
- return re_kw.sub(kwexpander, data)
- return data
+ def add(self, text, meta, tr, link, p1=None, p2=None):
+ if not util.binary(text):
+ re_kw = re.compile(r'\$(%s): [^$]+? \$' % hgkeywords)
+ text = re_kw.sub(r'$\1$', text)
+ return super(kwfilelog, self).add(text, meta, tr, link, p1, p2)
def size(self, rev):
'''Overrides filelog's size() to use kwfilelog.read().'''