Bug 4259 - templater: ifcontains doesn't actually work on lists
Summary: templater: ifcontains doesn't actually work on lists
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: 3.0
Hardware: PC Linux
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-23 17:08 UTC by Matt Mackall
Modified: 2014-07-19 14:17 UTC (History)
3 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Mackall 2014-05-23 17:08 UTC

    
Comment 1 Matt Mackall 2014-05-23 17:12 UTC
$ hg log -T '{ifcontains(rev, revset("1"), "{rev}\n")}'
1
$ hg log -T '{ifcontains(rev, revset("1 or 2"), "{rev}\n")}'
$

The ifcontains check ends up doing:

 if "1" in ["1 2"]:

..so it doesn't work for lists of more than one element.
Comment 2 Durham Goode 2014-05-23 20:13 UTC
Patch sent to the list with a fix.
Comment 3 HG Bot 2014-05-26 21:45 UTC
Fixed by http://selenic.com/repo/hg/rev/d8fb835376d1
Durham Goode <durham@fb.com>
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.

(please test the fix)