mercurial/templatefuncs.py
changeset 37163 0fb28899e81a
parent 37015 a318bb154d42
child 37210 2a2ce93e12f4
equal deleted inserted replaced
37162:9ab3491f84c2 37163:0fb28899e81a
    32 evalfuncarg = templateutil.evalfuncarg
    32 evalfuncarg = templateutil.evalfuncarg
    33 evalboolean = templateutil.evalboolean
    33 evalboolean = templateutil.evalboolean
    34 evalinteger = templateutil.evalinteger
    34 evalinteger = templateutil.evalinteger
    35 evalstring = templateutil.evalstring
    35 evalstring = templateutil.evalstring
    36 evalstringliteral = templateutil.evalstringliteral
    36 evalstringliteral = templateutil.evalstringliteral
    37 evalastype = templateutil.evalastype
       
    38 
    37 
    39 # dict of template built-in functions
    38 # dict of template built-in functions
    40 funcs = {}
    39 funcs = {}
    41 templatefunc = registrar.templatefunc(funcs)
    40 templatefunc = registrar.templatefunc(funcs)
    42 
    41 
   259     if not (3 <= len(args) <= 4):
   258     if not (3 <= len(args) <= 4):
   260         # i18n: "ifcontains" is a keyword
   259         # i18n: "ifcontains" is a keyword
   261         raise error.ParseError(_("ifcontains expects three or four arguments"))
   260         raise error.ParseError(_("ifcontains expects three or four arguments"))
   262 
   261 
   263     haystack = evalfuncarg(context, mapping, args[1])
   262     haystack = evalfuncarg(context, mapping, args[1])
   264     try:
   263     keytype = getattr(haystack, 'keytype', None)
   265         needle = evalastype(context, mapping, args[0],
   264     try:
   266                             getattr(haystack, 'keytype', None) or bytes)
   265         needle = evalrawexp(context, mapping, args[0])
       
   266         needle = templateutil.unwrapastype(needle, keytype or bytes)
   267         found = (needle in haystack)
   267         found = (needle in haystack)
   268     except error.ParseError:
   268     except error.ParseError:
   269         found = False
   269         found = False
   270 
   270 
   271     if found:
   271     if found: