Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templateutil.py @ 37502:40c7347f6848
formatter: remove template resources from nested items before generating JSON
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 17 Mar 2018 23:34:38 +0900 |
parents | 75c13343cf38 |
children | 61cecab0cc20 |
line wrap: on
line diff
--- a/mercurial/templateutil.py Thu Mar 15 21:09:37 2018 +0900 +++ b/mercurial/templateutil.py Sat Mar 17 23:34:38 2018 +0900 @@ -200,7 +200,14 @@ return self.join(context, mapping, self._defaultsep) def tovalue(self, context, mapping): - return list(self.itermaps(context)) + knownres = context.knownresourcekeys() + items = [] + for nm in self.itermaps(context): + # drop internal resources (recursively) which shouldn't be displayed + lm = context.overlaymap(mapping, nm) + items.append({k: unwrapvalue(context, lm, v) + for k, v in nm.iteritems() if k not in knownres}) + return items class mappinggenerator(_mappingsequence): """Wrapper for generator of template mappings