# HG changeset patch # User Yuya Nishihara # Date 1529219438 -32400 # Node ID b6294c113794794b6379d8520aeca86208f27658 # Parent 5b04a0c30f3f917d55ea2498a125871343e10aa7 templater: fix truth testing of integer 0 taken from a list/dict Broken at f9c426385853. bool(python_value) shouldn't be used here since an integer 0 has to be truthy for backward compatibility. diff -r 5b04a0c30f3f -r b6294c113794 mercurial/templateutil.py --- a/mercurial/templateutil.py Mon Jun 18 21:58:04 2018 +0900 +++ b/mercurial/templateutil.py Sun Jun 17 16:10:38 2018 +0900 @@ -350,7 +350,8 @@ return gen def tobool(self, context, mapping): - return bool(self.tovalue(context, mapping)) + w = makewrapped(context, mapping, self._value) + return w.tobool(context, mapping) def tovalue(self, context, mapping): return _unthunk(context, mapping, self._value) diff -r 5b04a0c30f3f -r b6294c113794 tests/test-template-functions.t --- a/tests/test-template-functions.t Mon Jun 18 21:58:04 2018 +0900 +++ b/tests/test-template-functions.t Sun Jun 17 16:10:38 2018 +0900 @@ -932,6 +932,8 @@ rev 0 is True $ hg log -r 0 -T '{if(0, "literal 0 is True as well")}\n' literal 0 is True as well + $ hg log -r 0 -T '{if(min(revset(r"0")), "0 of hybriditem is also True")}\n' + 0 of hybriditem is also True $ hg log -r 0 -T '{if("", "", "empty string is False")}\n' empty string is False $ hg log -r 0 -T '{if(revset(r"0 - 0"), "", "empty list is False")}\n'