Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/webutil.py @ 38267:fb874fc1d9b4
templater: abstract ifcontains() over wrapped types
This allows us to make .keytype private.
There's a minor BC that a hybrid dict/list of keytype=None now strictly
checks the type of the needle. For example, {ifcontains(rev, files)} no longer
matches a file named "1" at the rev=1. I made this change for consistency
with the get(dict, key) function. We can restore the old behavior by making
keytype=bytes the default if desired.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 19 Mar 2018 00:23:20 +0900 |
parents | 41ae9b3cbfb9 |
children | f9c426385853 |
comparison
equal
deleted
inserted
replaced
38266:80f423a14c90 | 38267:fb874fc1d9b4 |
---|---|
711 self._vars[key] = value | 711 self._vars[key] = value |
712 | 712 |
713 def __copy__(self): | 713 def __copy__(self): |
714 return sessionvars(copy.copy(self._vars), self._start) | 714 return sessionvars(copy.copy(self._vars), self._start) |
715 | 715 |
716 def contains(self, context, mapping, item): | |
717 item = templateutil.unwrapvalue(context, mapping, item) | |
718 return item in self._vars | |
719 | |
716 def getmember(self, context, mapping, key): | 720 def getmember(self, context, mapping, key): |
717 key = templateutil.unwrapvalue(context, mapping, key) | 721 key = templateutil.unwrapvalue(context, mapping, key) |
718 return self._vars.get(key) | 722 return self._vars.get(key) |
719 | 723 |
720 def getmin(self, context, mapping): | 724 def getmin(self, context, mapping): |