From patchwork Tue Aug 25 14:12:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,3] templater: inline getfilter() to buildfilter() From: Yuya Nishihara X-Patchwork-Id: 10270 Message-Id: To: mercurial-devel@selenic.com Date: Tue, 25 Aug 2015 23:12:59 +0900 # HG changeset patch # User Yuya Nishihara # Date 1435993143 -32400 # Sat Jul 04 15:59:03 2015 +0900 # Node ID d78be71877dfacd9e1980b7c9ceb6bfd5b859417 # Parent 05e7f57c74ac5b556b49870af86f61aa0c54babb templater: inline getfilter() to buildfilter() This prepares for the unified filter syntax that will be introduced by the next patch. diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -205,12 +205,6 @@ def getlist(x): return getlist(x[1]) + [x[2]] return [x] -def getfilter(exp, context): - f = getsymbol(exp) - if f not in context._filters: - raise error.ParseError(_("unknown function '%s'") % f) - return context._filters[f] - def gettemplate(exp, context): if exp[0] == 'template': return [compileexp(e, context, methods) for e in exp[1]] @@ -254,8 +248,11 @@ def runtemplate(context, mapping, templa def buildfilter(exp, context): func, data = compileexp(exp[1], context, methods) - filt = getfilter(exp[2], context) - return (runfilter, (func, data, filt)) + n = getsymbol(exp[2]) + if n in context._filters: + filt = context._filters[n] + return (runfilter, (func, data, filt)) + raise error.ParseError(_("unknown function '%s'") % n) def runfilter(context, mapping, data): func, data, filt = data