comparison 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
comparison
equal deleted inserted replaced
37501:0f4de9c27973 37502:40c7347f6848
198 198
199 def show(self, context, mapping): 199 def show(self, context, mapping):
200 return self.join(context, mapping, self._defaultsep) 200 return self.join(context, mapping, self._defaultsep)
201 201
202 def tovalue(self, context, mapping): 202 def tovalue(self, context, mapping):
203 return list(self.itermaps(context)) 203 knownres = context.knownresourcekeys()
204 items = []
205 for nm in self.itermaps(context):
206 # drop internal resources (recursively) which shouldn't be displayed
207 lm = context.overlaymap(mapping, nm)
208 items.append({k: unwrapvalue(context, lm, v)
209 for k, v in nm.iteritems() if k not in knownres})
210 return items
204 211
205 class mappinggenerator(_mappingsequence): 212 class mappinggenerator(_mappingsequence):
206 """Wrapper for generator of template mappings 213 """Wrapper for generator of template mappings
207 214
208 The function ``make(context, *args)`` should return a generator of 215 The function ``make(context, *args)`` should return a generator of