Mercurial > hg
diff hgext/keyword.py @ 28694:9a6fa1d93bc8
keyword: use templatefilter to mark a function as template filter
This patch also adds test for filter 'svnisodate' and 'svnutcdate' for
safety, because there is no test using them, yet.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 30 Mar 2016 02:10:44 +0900 |
parents | 311472301ef3 |
children | 4a65c9c6cd3f |
line wrap: on
line diff
--- a/hgext/keyword.py Wed Mar 30 02:10:44 2016 +0900 +++ b/hgext/keyword.py Wed Mar 30 02:10:44 2016 +0900 @@ -104,6 +104,7 @@ match, patch, pathutil, + registrar, scmutil, templatefilters, util, @@ -137,28 +138,29 @@ 'kwfiles.ignoredunknown': 'none' } +templatefilter = registrar.templatefilter() + # date like in cvs' $Date +@templatefilter('utcdate') def utcdate(text): - ''':utcdate: Date. Returns a UTC-date in this format: "2009/08/18 11:00:13". + '''Date. Returns a UTC-date in this format: "2009/08/18 11:00:13". ''' return util.datestr((util.parsedate(text)[0], 0), '%Y/%m/%d %H:%M:%S') # date like in svn's $Date +@templatefilter('svnisodate') def svnisodate(text): - ''':svnisodate: Date. Returns a date in this format: "2009-08-18 13:00:13 + '''Date. Returns a date in this format: "2009-08-18 13:00:13 +0200 (Tue, 18 Aug 2009)". ''' return util.datestr(text, '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)') # date like in svn's $Id +@templatefilter('svnutcdate') def svnutcdate(text): - ''':svnutcdate: Date. Returns a UTC-date in this format: "2009-08-18 + '''Date. Returns a UTC-date in this format: "2009-08-18 11:00:13Z". ''' return util.datestr((util.parsedate(text)[0], 0), '%Y-%m-%d %H:%M:%SZ') -templatefilters.filters.update({'utcdate': utcdate, - 'svnisodate': svnisodate, - 'svnutcdate': svnutcdate}) - # make keyword tools accessible kwtools = {'templater': None, 'hgcmd': ''}