Patchwork [1,of,3] templater: inline getfilter() to buildfilter()

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 25, 2015, 2:12 p.m.
Message ID <d78be71877dfacd9e198.1440511979@mimosa>
Download mbox | patch
Permalink /patch/10270/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 25, 2015, 2:12 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# 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.

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