mercurial/templateutil.py
changeset 40952 4591c9791a82
parent 40525 8fa26f3baf30
child 42359 832c59d1196e
--- a/mercurial/templateutil.py	Wed Dec 12 22:19:57 2018 +0900
+++ b/mercurial/templateutil.py	Wed Dec 12 22:45:02 2018 +0900
@@ -495,6 +495,19 @@
     def tovalue(self, context, mapping):
         return super(mappingdict, self).tovalue(context, mapping)[0]
 
+class mappingnone(wrappedvalue):
+    """Wrapper for None, but supports map operation
+
+    This represents None of Optional[mappable]. It's similar to
+    mapplinglist([]), but the underlying value is not [], but None.
+    """
+
+    def __init__(self):
+        super(mappingnone, self).__init__(None)
+
+    def itermaps(self, context):
+        return iter([])
+
 class mappedgenerator(wrapped):
     """Wrapper for generator of strings which acts as a list