comparison mercurial/templater.py @ 21540:d8fb835376d1 stable

templates: fix ifcontains against sets with length > 1 (issue4259) Previously the ifcontains revset was checking against the set using a pure __contains__ check. It turns out the set was actually a list of formatted strings meant for ui output, which meant the contains check failed if the formatted string wasn't significantly different from the raw value. This change makes it check against the raw data, prior to it being formatted.
author Durham Goode <durham@fb.com>
date Fri, 23 May 2014 16:25:55 -0700
parents 81d6dc8c3c63
children f2c617ff2abc
comparison
equal deleted inserted replaced
21229:54d7657d7d1e 21540:d8fb835376d1
308 raise error.ParseError(_("ifcontains expects three or four arguments")) 308 raise error.ParseError(_("ifcontains expects three or four arguments"))
309 309
310 item = stringify(args[0][0](context, mapping, args[0][1])) 310 item = stringify(args[0][0](context, mapping, args[0][1]))
311 items = args[1][0](context, mapping, args[1][1]) 311 items = args[1][0](context, mapping, args[1][1])
312 312
313 if item in items: 313 # Iterating over items gives a formatted string, so we iterate
314 # directly over the raw values.
315 if item in [i.values()[0] for i in items()]:
314 yield _evalifliteral(args[2], context, mapping) 316 yield _evalifliteral(args[2], context, mapping)
315 elif len(args) == 4: 317 elif len(args) == 4:
316 yield _evalifliteral(args[3], context, mapping) 318 yield _evalifliteral(args[3], context, mapping)
317 319
318 def ifeq(context, mapping, args): 320 def ifeq(context, mapping, args):