diff mercurial/templateutil.py @ 38298:851fc9d42d6d

templater: make date wrapper support dot/map operations No idea if it will be useful, but it just works.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 24 Mar 2018 17:59:19 +0900
parents 8d6109b49b31
children f9c426385853
line wrap: on
line diff
--- a/mercurial/templateutil.py	Sat Mar 24 17:54:02 2018 +0900
+++ b/mercurial/templateutil.py	Sat Mar 24 17:59:19 2018 +0900
@@ -172,7 +172,7 @@
     def tovalue(self, context, mapping):
         return self._value
 
-class date(wrapped):
+class date(mappable, wrapped):
     """Wrapper for date tuple"""
 
     def __init__(self, value):
@@ -192,15 +192,15 @@
     def getmax(self, context, mapping):
         raise error.ParseError(_('date is not iterable'))
 
-    def itermaps(self, context):
-        raise error.ParseError(_("date is not iterable"))
-
     def join(self, context, mapping, sep):
         raise error.ParseError(_("date is not iterable"))
 
     def show(self, context, mapping):
         return '%d %d' % (self._unixtime, self._tzoffset)
 
+    def tomap(self, context):
+        return {'unixtime': self._unixtime, 'tzoffset': self._tzoffset}
+
     def tovalue(self, context, mapping):
         return (self._unixtime, self._tzoffset)