hgkw/keyword.py
branchextension
changeset 34 3a79665dcbc3
parent 33 ebb39c6a1476
child 36 b3ace8cc5a33
--- a/hgkw/keyword.py	Tue Dec 19 09:39:03 2006 +0100
+++ b/hgkw/keyword.py	Tue Dec 19 09:56:41 2006 +0100
@@ -1,5 +1,5 @@
 from mercurial import hg, filelog, revlog, context, util
-import re
+import os.path, re
 
 def reposetup(ui, repo):
     if not repo.local():
@@ -23,17 +23,18 @@
                 self._repo.ui.config("keywords", "expand", True)):
                 c = context.filectx(self._repo, self._path, fileid=node,
                                      filelog=self)
-                def author(): return "$Author %s $" % c.user()
-                def date(): return "$Date %s $" % util.datestr(c.date())
-
-                data = re.sub(r'\$Author\$', author(), data)
-                data = re.sub(r'\$Date\$', date(), data)
+                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)
             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)):
-                text = re.sub(r'\$Author[^\$]*\$', '$Author$', text)
-                text = re.sub(r'\$Date[^\$]*\$', '$Date$', text)
+                text = re.sub(r'\$Hg[^$]*?\$', '$Hg$', text)
             return super(kwfilelog, self).add(text, meta, tr, link, p1, p2)
 
     filelog.filelog = kwfilelog