mercurial/templater.py
changeset 17383 099c778ceb33
parent 17334 39c01f8e7b39
child 17631 0b241d7a8c62
equal deleted inserted replaced
17352:c6f88e7f95b7 17383:099c778ceb33
   144     filt = getfilter(exp[2], context)
   144     filt = getfilter(exp[2], context)
   145     return (runfilter, (func, data, filt))
   145     return (runfilter, (func, data, filt))
   146 
   146 
   147 def runfilter(context, mapping, data):
   147 def runfilter(context, mapping, data):
   148     func, data, filt = data
   148     func, data, filt = data
   149     return filt(func(context, mapping, data))
   149     try:
       
   150         return filt(func(context, mapping, data))
       
   151     except (ValueError, AttributeError, TypeError):
       
   152         if isinstance(data, tuple):
       
   153             dt = data[1]
       
   154         else:
       
   155             dt = data
       
   156         raise util.Abort(_("template filter '%s' is not compatible with "
       
   157                            "keyword '%s'") % (filt.func_name, dt))
   150 
   158 
   151 def buildmap(exp, context):
   159 def buildmap(exp, context):
   152     func, data = compileexp(exp[1], context)
   160     func, data = compileexp(exp[1], context)
   153     ctmpl = gettemplate(exp[2], context)
   161     ctmpl = gettemplate(exp[2], context)
   154     return (runmap, (func, data, ctmpl))
   162     return (runmap, (func, data, ctmpl))