changeset 30049:f18cc848b48e

templater: use "needle" and "haystack" as (meta-)variables for ifcontains() It wasn't immediately clear if it's supposed to look for "search" in "thing" or "thing" in "search".
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 01 Oct 2016 09:55:32 +0800
parents 91a3c58ecf93
children d229be12e256
files mercurial/templater.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templater.py	Mon Oct 03 13:24:56 2016 +0200
+++ b/mercurial/templater.py	Sat Oct 01 09:55:32 2016 +0800
@@ -596,18 +596,18 @@
     elif len(args) == 3:
         yield args[2][0](context, mapping, args[2][1])
 
-@templatefunc('ifcontains(search, thing, then[, else])')
+@templatefunc('ifcontains(needle, haystack, then[, else])')
 def ifcontains(context, mapping, args):
     """Conditionally execute based
-    on whether the item "search" is in "thing"."""
+    on whether the item "needle" is in "haystack"."""
     if not (3 <= len(args) <= 4):
         # i18n: "ifcontains" is a keyword
         raise error.ParseError(_("ifcontains expects three or four arguments"))
 
-    item = evalstring(context, mapping, args[0])
-    items = evalfuncarg(context, mapping, args[1])
+    needle = evalstring(context, mapping, args[0])
+    haystack = evalfuncarg(context, mapping, args[1])
 
-    if item in items:
+    if needle in haystack:
         yield args[2][0](context, mapping, args[2][1])
     elif len(args) == 4:
         yield args[3][0](context, mapping, args[3][1])