# HG changeset patch # User Yuya Nishihara <y...@tcha.org> # Date 1521386815 -32400 # Mon Mar 19 00:26:55 2018 +0900 # Node ID 1b491a1ed8847e48efad64786c4f09909cce5c5f # Parent 8fc143c310c8154b978df8509929b8ac9940029b templater: drop hybrid-ness on unwrapvalue()
Proxy methods are no longer necessary as list/dict functions go through the wrapped interface. diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -235,22 +235,12 @@ class hybrid(wrapped): return gen def tovalue(self, context, mapping): - # TODO: return self._values and get rid of proxy methods - return self - - def __contains__(self, x): - return x in self._values - def __getitem__(self, key): - return self._values[key] - def __len__(self): - return len(self._values) - def __iter__(self): - return iter(self._values) - def __getattr__(self, name): - if name not in (r'get', r'items', r'iteritems', r'iterkeys', - r'itervalues', r'keys', r'values'): - raise AttributeError(name) - return getattr(self._values, name) + # TODO: make it non-recursive for trivial lists/dicts + xs = self._values + if util.safehasattr(xs, 'get'): + return {k: unwrapvalue(context, mapping, v) + for k, v in xs.iteritems()} + return [unwrapvalue(context, mapping, x) for x in xs] class mappable(wrapped): """Wrapper for non-list/dict object to support map operation @@ -259,9 +249,6 @@ class mappable(wrapped): - "{manifest}" - "{manifest % '{rev}:{node}'}" - "{manifest.rev}" - - Unlike a hybrid, this does not simulate the behavior of the underling - value. """ def __init__(self, gen, key, value, makemap): _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel