# HG changeset patch # User Christian Ebert # Date 1166539305 -3600 # Node ID b3ace8cc5a33b48b1a877aecc93bb2d34501ca59 # Parent a730c9d4ec058795f42adc780b9731a7dcbd7130 Change config opt "expand" to accept filename patterns Not nice yet; but passes tests together with pretxnkw. TODO: Find out what filelog.add() does exactly. diff -r a730c9d4ec05 -r b3ace8cc5a33 hgkw/keyword.py --- a/hgkw/keyword.py Tue Dec 19 10:00:28 2006 +0100 +++ b/hgkw/keyword.py Tue Dec 19 15:41:45 2006 +0100 @@ -17,23 +17,34 @@ super(kwfilelog, self).__init__(opener, path, defversion) self._repo = repo self._path = path + def read(self, node): - data = super(kwfilelog, self).read(node) - if (not util.binary(data) and - self._repo.ui.config("keywords", "expand", True)): + def gethgkw(): c = context.filectx(self._repo, self._path, fileid=node, filelog=self) - hgkw = '$Hg: %s,v %s %s %s $' % ( - os.path.basename(c.path()), - c.changectx(), - util.datestr(date=c.date(), - format=util.defaultdateformats[0]), - util.shortuser(c.user())) - data = data.replace('$Hg$', hgkw) + filename = c.path() + for pat, opt in self._repo.ui.configitems('keyword'): + if opt == 'expand': + mf = util.matcher(self._repo.root, + '', [pat], [], [])[1] + if mf(filename): + return '$Hg: %s,v %s %s %s $' % ( + os.path.basename(filename), + c.changectx(), + util.datestr(date=c.date(), + format=util.defaultdateformats[0]), + util.shortuser(c.user()) + ) + data = super(kwfilelog, self).read(node) + if not util.binary(data): + hgkw = gethgkw() + if hgkw: + data = data.replace('$Hg$', hgkw) return data + def add(self, text, meta, tr, link, p1=None, p2=None): if (not util.binary(text) and - self._repo.ui.config("keywords", "remove", True)): + self._repo.ui.config('keyword', 'remove', True)): text = re.sub(r'\$Hg[^$]*?\$', '$Hg$', text) return super(kwfilelog, self).add(text, meta, tr, link, p1, p2)