keyword: add 2 svn-like date filters
authorChristian Ebert <blacktrash@gmx.net>
Tue, 18 May 2010 22:16:38 +0200
changeset 11213 3d61813a300e
parent 11212 4d8db9676171
child 11214 b05ec0cc063e
keyword: add 2 svn-like date filters svnisodate yields the format the date in svn's Id keyword expands to. svnutcdate yields the format svn's Date/LastChangedDate expands to. http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html
hgext/keyword.py
--- a/hgext/keyword.py	Fri May 21 19:54:40 2010 +0900
+++ b/hgext/keyword.py	Tue May 18 22:16:38 2010 +0200
@@ -52,8 +52,11 @@
 control run :hg:`kwdemo`. See :hg:`help templates` for a list of
 available templates and filters.
 
-An additional date template filter {date|utcdate} is provided. It
-returns a date like "2006/09/18 15:13:13".
+Three additional date template filters are provided::
+
+    utcdate      "2006/09/18 15:13:13"
+    svnutcdate   "2006-09-18 15:13:13Z"
+    svnisodate   "2006-09-18 08:13:13 -700 (Mon, 18 Sep 2006)"
 
 The default template mappings (view with :hg:`kwdemo -d`) can be
 replaced with customized keywords and templates. Again, run
@@ -94,8 +97,12 @@
 # names of extensions using dorecord
 recordextensions = 'record'
 
-# provide cvs-like UTC date filter
+# date like in cvs' $Date
 utcdate = lambda x: util.datestr((x[0], 0), '%Y/%m/%d %H:%M:%S')
+# date like in svn's $Date
+svnisodate = lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)')
+# date like in svn's $Id
+svnutcdate = lambda x: util.datestr((x[0], 0), '%Y-%m-%d %H:%M:%SZ')
 
 # make keyword tools accessible
 kwtools = {'templater': None, 'hgcmd': '', 'inc': [], 'exc': ['.hg*']}
@@ -135,6 +142,8 @@
         self.re_kw = re.compile(kwpat)
 
         templatefilters.filters['utcdate'] = utcdate
+        templatefilters.filters['svnisodate'] = svnisodate
+        templatefilters.filters['svnutcdate'] = svnutcdate
 
     def substitute(self, data, path, ctx, subfunc):
         '''Replaces keywords in data with expanded template.'''