--- a/mercurial/templater.py Thu Oct 12 21:56:13 2017 +0900
+++ b/mercurial/templater.py Thu Oct 12 22:09:11 2017 +0900
@@ -797,10 +797,14 @@
raise error.ParseError(_("ifcontains expects three or four arguments"))
haystack = evalfuncarg(context, mapping, args[1])
- needle = evalastype(context, mapping, args[0],
- getattr(haystack, 'keytype', None) or bytes)
+ try:
+ needle = evalastype(context, mapping, args[0],
+ getattr(haystack, 'keytype', None) or bytes)
+ found = (needle in haystack)
+ except error.ParseError:
+ found = False
- if needle in haystack:
+ if found:
yield evalrawexp(context, mapping, args[2])
elif len(args) == 4:
yield evalrawexp(context, mapping, args[3])