Patchwork [1,of,5] templater: do dict lookup over a wrapped object

login
register
mail settings
Submitter Yuya Nishihara
Date June 5, 2018, 1:18 p.m.
Message ID <f028d9f94272b971eafc.1528204735@mimosa>
Download mbox | patch
Permalink /patch/31981/
State Accepted
Headers show

Comments

Yuya Nishihara - June 5, 2018, 1:18 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521562709 -32400
#      Wed Mar 21 01:18:29 2018 +0900
# Node ID f028d9f94272b971eafc60582af15d83cc9a8f4a
# Parent  2b8c8b8d1a0698c7b045053806368c9a05ee9fd0
templater: do dict lookup over a wrapped object

Dict/list lookup operations will be moved to a wrapped interface so that
a returned element can inherit hybrid-ness automatically. wraphybridvalue()
will be inlined.

Patch

diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py
--- a/mercurial/templatefuncs.py
+++ b/mercurial/templatefuncs.py
@@ -261,7 +261,7 @@  def get(context, mapping, args):
         # i18n: "get" is a keyword
         raise error.ParseError(_("get() expects two arguments"))
 
-    dictarg = evalfuncarg(context, mapping, args[0])
+    dictarg = evalwrapped(context, mapping, args[0])
     if not util.safehasattr(dictarg, 'get'):
         # i18n: "get" is a keyword
         raise error.ParseError(_("get() expects a dict as first argument"))
diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py
--- a/mercurial/templateutil.py
+++ b/mercurial/templateutil.py
@@ -662,7 +662,7 @@  def runmap(context, mapping, data):
 
 def runmember(context, mapping, data):
     darg, memb = data
-    d = evalrawexp(context, mapping, darg)
+    d = evalwrapped(context, mapping, darg)
     if util.safehasattr(d, 'tomap'):
         lm = context.overlaymap(mapping, d.tomap())
         return runsymbol(context, lm, memb)