comparison mercurial/formatter.py @ 43337:7e20b705da5b stable

formatter: fix handling of None value in templater mapping For historical reasons, None in mapping dict means there's no such keyword, and falls back to b"". That's fine in log templates where mapping item is generally a callable returning a value (which may be None,) but the formatter directly puts an "evaluated" value in the mapping. So the None value has to be lifted to wrappedvalue(None) to avoid confusion in the template engine.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 27 Oct 2019 12:49:09 +0900
parents 242ad45b60b3
children 653b2a439412
comparison
equal deleted inserted replaced
43336:a71578ec6257 43337:7e20b705da5b
513 513
514 def _renderitem(self, part, item): 514 def _renderitem(self, part, item):
515 if part not in self._parts: 515 if part not in self._parts:
516 return 516 return
517 ref = self._parts[part] 517 ref = self._parts[part]
518 # None can't be put in the mapping dict since it means <unset>
519 for k, v in item.items():
520 if v is None:
521 item[k] = templateutil.wrappedvalue(v)
518 self._out.write(self._t.render(ref, item)) 522 self._out.write(self._t.render(ref, item))
519 523
520 @util.propertycache 524 @util.propertycache
521 def _symbolsused(self): 525 def _symbolsused(self):
522 return self._t.symbolsused(self._tref) 526 return self._t.symbolsused(self._tref)