# HG changeset patch # User Yuya Nishihara # Date 2018-03-21 03:06:18 # Node ID 80f423a14c90fef3090d564dac8db4949bfaae55 # Parent 41ae9b3cbfb9c4e938213aa1c39836d39baaf4a6 templater: inline wraphybridvalue() All wraphybridvalue() calls are now handled in the hybrid class. diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -193,7 +193,10 @@ class hybrid(wrapped): def _wrapvalue(self, key, val): if val is None: return - return wraphybridvalue(self, key, val) + 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) def itermaps(self, context): makemap = self._makemap @@ -422,20 +425,6 @@ def unwraphybrid(context, mapping, thing return thing return thing.show(context, mapping) -def wraphybridvalue(container, key, value): - """Wrap an element of hybrid container to be mappable - - The key is passed to the makemap function of the given container, which - should be an item generated by iter(container). - """ - makemap = getattr(container, '_makemap', None) - if makemap is None: - return value - if util.safehasattr(value, '_makemap'): - # a nested hybrid list/dict, which has its own way of map operation - return value - return mappable(None, key, value, makemap) - def compatdict(context, mapping, name, data, key='key', value='value', fmt=None, plural=None, separator=' '): """Wrap data like hybriddict(), but also supports old-style list template