diff 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
line wrap: on
line diff
--- a/mercurial/templater.py	Mon May 05 16:54:15 2014 +0200
+++ b/mercurial/templater.py	Fri May 23 16:25:55 2014 -0700
@@ -310,7 +310,9 @@
     item = stringify(args[0][0](context, mapping, args[0][1]))
     items = args[1][0](context, mapping, args[1][1])
 
-    if item in items:
+    # Iterating over items gives a formatted string, so we iterate
+    # directly over the raw values.
+    if item in [i.values()[0] for i in items()]:
         yield _evalifliteral(args[2], context, mapping)
     elif len(args) == 4:
         yield _evalifliteral(args[3], context, mapping)