comparison mercurial/branchmap.py @ 42113:f0def07fa82f

branchmap: implement __contains__() We have good occurences of `if branch in branchmap()` in our code. If __contains__() is not implemented then it will use __iter__() to find whether the element exists or not which is not good. I am bit confused that whether I should move existing callers to hasbranch() or this patch is a good way. Differential Revision: https://phab.mercurial-scm.org/D6206
author Pulkit Goyal <pulkit@yandex-team.ru>
date Sun, 31 Mar 2019 16:27:10 +0300
parents 29c22496dd97
children 2f8147521e59
comparison
equal deleted inserted replaced
42112:29c22496dd97 42113:f0def07fa82f
179 def __setitem__(self, key, value): 179 def __setitem__(self, key, value):
180 self._entries[key] = value 180 self._entries[key] = value
181 181
182 def __getitem__(self, key): 182 def __getitem__(self, key):
183 return self._entries[key] 183 return self._entries[key]
184
185 def __contains__(self, key):
186 return key in self._entries
184 187
185 def iteritems(self): 188 def iteritems(self):
186 return self._entries.iteritems() 189 return self._entries.iteritems()
187 190
188 def hasbranch(self, label): 191 def hasbranch(self, label):