# HG changeset patch # User Christian Ebert # Date 1274472759 -7200 # Node ID c39a201b2b7fdcf6534543f2266114ee7a1f413b # Parent 53df72b60f067e7d6048dc10d6683a192f6242fa 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 diff -r 53df72b60f06 -r c39a201b2b7f hgkw/keyword.py --- a/hgkw/keyword.py Tue May 18 22:22:59 2010 +0200 +++ b/hgkw/keyword.py Fri May 21 22:12:39 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.'''