Patchwork [4,of,7] templater: drop bool support from evalastype()

login
register
mail settings
Submitter Yuya Nishihara
Date March 25, 2018, 5:15 a.m.
Message ID <8b71d63fb9cc8c635fab.1521954951@mimosa>
Download mbox | patch
Permalink /patch/29841/
State Accepted
Headers show

Comments

Yuya Nishihara - March 25, 2018, 5:15 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521804235 -32400
#      Fri Mar 23 20:23:55 2018 +0900
# Node ID 8b71d63fb9cc8c635fab41b872b8db6d5279a58a
# Parent  63e4b6939689ee90bb27cd6522903bf44c349952
templater: drop bool support from evalastype()

Future patches will split evalastype() into two functions, evalrawexp()
and unwrapastype(), so we can catch the exception of type conversion.

  # evaluating function may bubble up inner ParseError
  thing = evalrawexp(context, mapping, arg)
  try:
      return unwrapastype(context, thing)
  except ParseError:
      # add hint and reraise

However, evalboolean() can't be factored out in this way since it has to
process boolean-like symbols as non keyword. Fortunately, it's unlikely
that we'll need a general type converter supporting bool, so this patch
drops it from the table.

Patch

diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py
--- a/mercurial/templateutil.py
+++ b/mercurial/templateutil.py
@@ -333,7 +333,6 @@  def evalstringliteral(context, mapping, 
     return stringify(thing)
 
 _evalfuncbytype = {
-    bool: evalboolean,
     bytes: evalstring,
     int: evalinteger,
 }