comparison mercurial/templater.py @ 28332:e91371633127

templater: fix ifcontains() to evaluate items argument eagerly See the previous patch for why. An "items" argument may be a string, a generator, or an arbitrary container object.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 14 Feb 2016 00:18:12 +0900
parents 2874db5462d3
children 41373244f4e5
comparison
equal deleted inserted replaced
28331:2874db5462d3 28332:e91371633127
464 if not (3 <= len(args) <= 4): 464 if not (3 <= len(args) <= 4):
465 # i18n: "ifcontains" is a keyword 465 # i18n: "ifcontains" is a keyword
466 raise error.ParseError(_("ifcontains expects three or four arguments")) 466 raise error.ParseError(_("ifcontains expects three or four arguments"))
467 467
468 item = stringify(args[0][0](context, mapping, args[0][1])) 468 item = stringify(args[0][0](context, mapping, args[0][1]))
469 items = args[1][0](context, mapping, args[1][1]) 469 items = evalfuncarg(context, mapping, args[1])
470 470
471 if item in items: 471 if item in items:
472 yield args[2][0](context, mapping, args[2][1]) 472 yield args[2][0](context, mapping, args[2][1])
473 elif len(args) == 4: 473 elif len(args) == 4:
474 yield args[3][0](context, mapping, args[3][1]) 474 yield args[3][0](context, mapping, args[3][1])