# HG changeset patch # User Christian Ebert # Date 1167327714 -3600 # Node ID 1ecb6ec5d16b372de925e61fae7e5f98011aa95f # Parent fe891f87a16cf6da06d8bea5b6eaf7f6cf76a13c Reintroduce simpler kwfilelog.add(); simplify kwfilelog.read() Without add() strange things happen to changectx(). diff -r fe891f87a16c -r 1ecb6ec5d16b hgkw/keyword.py --- 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().'''