# HG changeset patch # User Yuya Nishihara # Date 1525405395 -32400 # Node ID 688fbb758ba993d5648619b4ce03b71f1c5719d4 # Parent 06d11cd905166ed5a8aa300abff4b5f5ef052c2b templater: resolve type of dict key in getmember() This seems more correct and is consistent with the future wrapped.contains() function, where a key type has to be resolved depending on a container type. diff -r 06d11cd90516 -r 688fbb758ba9 mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py Wed Mar 21 11:30:21 2018 +0900 +++ b/mercurial/hgweb/webutil.py Fri May 04 12:43:15 2018 +0900 @@ -714,6 +714,7 @@ return sessionvars(copy.copy(self._vars), self._start) def getmember(self, context, mapping, key): + key = templateutil.unwrapvalue(context, mapping, key) return self._vars.get(key) def itermaps(self, context): diff -r 06d11cd90516 -r 688fbb758ba9 mercurial/templatefuncs.py --- a/mercurial/templatefuncs.py Wed Mar 21 11:30:21 2018 +0900 +++ b/mercurial/templatefuncs.py Fri May 04 12:43:15 2018 +0900 @@ -262,7 +262,7 @@ raise error.ParseError(_("get() expects two arguments")) dictarg = evalwrapped(context, mapping, args[0]) - key = evalfuncarg(context, mapping, args[1]) + key = evalrawexp(context, mapping, args[1]) try: return dictarg.getmember(context, mapping, key) except error.ParseError as err: diff -r 06d11cd90516 -r 688fbb758ba9 mercurial/templateutil.py --- a/mercurial/templateutil.py Wed Mar 21 11:30:21 2018 +0900 +++ b/mercurial/templateutil.py Fri May 04 12:43:15 2018 +0900 @@ -41,6 +41,7 @@ def getmember(self, context, mapping, key): """Return a member item for the specified key + The key argument may be a wrapped object. A returned object may be either a wrapped object or a pure value depending on the self type. """ @@ -147,6 +148,7 @@ # TODO: maybe split hybrid list/dict types? if not util.safehasattr(self._values, 'get'): raise error.ParseError(_('not a dictionary')) + key = unwrapastype(context, mapping, key, self.keytype) return self._wrapvalue(key, self._values.get(key)) def _wrapvalue(self, key, val):