--- 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)