[PATCH 1 of 7] templater: rename mappable to hybriditem as it is the primary use case

Yuya Nishihara yuya at tcha.org
Tue Jun 12 14:49:03 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1528515366 -32400
#      Sat Jun 09 12:36:06 2018 +0900
# Node ID 9c54939508aa66b09f2384ac37974addbabb90e9
# Parent  94e4a283c6d720f8b13978de9c750a4d0402f209
templater: rename mappable to hybriditem as it is the primary use case

This frees up the name 'mappable' for new interface type.

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -31,7 +31,6 @@ from .utils import (
 )
 
 _hybrid = templateutil.hybrid
-_mappable = templateutil.mappable
 hybriddict = templateutil.hybriddict
 hybridlist = templateutil.hybridlist
 compatdict = templateutil.compatdict
@@ -469,7 +468,8 @@ def showmanifest(context, mapping):
     f = context.process('manifest', mapping)
     # TODO: perhaps 'ctx' should be dropped from mapping because manifest
     # rev and node are completely different from changeset's.
-    return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex})
+    return templateutil.hybriditem(f, None, f,
+                                   lambda x: {'rev': mrev, 'node': mhex})
 
 @templatekeyword('obsfate', requires={'ui', 'repo', 'ctx'})
 def showobsfate(context, mapping):
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -42,7 +42,7 @@ hybrid
     represents a list/dict of printable values, which can also be converted
     to mappings by % operator.
 
-mappable
+hybriditem
     represents a scalar printable value, also supports % operator.
 
 mappinggenerator, mappinglist
diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py
--- a/mercurial/templateutil.py
+++ b/mercurial/templateutil.py
@@ -215,7 +215,7 @@ class hybrid(wrapped):
         if util.safehasattr(val, '_makemap'):
             # a nested hybrid list/dict, which has its own way of map operation
             return val
-        return mappable(None, key, val, self._makemap)
+        return hybriditem(None, key, val, self._makemap)
 
     def itermaps(self, context):
         makemap = self._makemap
@@ -243,7 +243,7 @@ class hybrid(wrapped):
                     for k, v in xs.iteritems()}
         return [unwrapvalue(context, mapping, x) for x in xs]
 
-class mappable(wrapped):
+class hybriditem(wrapped):
     """Wrapper for non-list/dict object to support map operation
 
     This class allows us to handle both:


More information about the Mercurial-devel mailing list