mercurial/templater.py
changeset 34659 3edfd472f3cb
parent 34581 ee0d74083a22
child 34693 56bb07a0b75c
--- 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])