mercurial/templatefuncs.py
changeset 38267 fb874fc1d9b4
parent 38265 41ae9b3cbfb9
child 38285 8d6109b49b31
equal deleted inserted replaced
38266:80f423a14c90 38267:fb874fc1d9b4
   289     on whether the item "needle" is in "haystack"."""
   289     on whether the item "needle" is in "haystack"."""
   290     if not (3 <= len(args) <= 4):
   290     if not (3 <= len(args) <= 4):
   291         # i18n: "ifcontains" is a keyword
   291         # i18n: "ifcontains" is a keyword
   292         raise error.ParseError(_("ifcontains expects three or four arguments"))
   292         raise error.ParseError(_("ifcontains expects three or four arguments"))
   293 
   293 
   294     haystack = evalfuncarg(context, mapping, args[1])
   294     haystack = evalwrapped(context, mapping, args[1])
   295     keytype = getattr(haystack, 'keytype', None)
       
   296     try:
   295     try:
   297         needle = evalrawexp(context, mapping, args[0])
   296         needle = evalrawexp(context, mapping, args[0])
   298         needle = templateutil.unwrapastype(context, mapping, needle,
   297         found = haystack.contains(context, mapping, needle)
   299                                            keytype or bytes)
       
   300         found = (needle in haystack)
       
   301     except error.ParseError:
   298     except error.ParseError:
   302         found = False
   299         found = False
   303 
   300 
   304     if found:
   301     if found:
   305         return evalrawexp(context, mapping, args[2])
   302         return evalrawexp(context, mapping, args[2])