Mercurial > public > mercurial-scm > hg
comparison mercurial/smartset.py @ 50925:d718eddf01d9
safehasattr: drop usage in favor of hasattr
The two functions should now be equivalent at least in their usage in core.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 31 Aug 2023 23:56:15 +0200 |
parents | f6cb926d4189 |
children | 18c8c18993f0 |
comparison
equal
deleted
inserted
replaced
50924:7a8ea1397816 | 50925:d718eddf01d9 |
---|---|
135 boolean. Optional `condrepr` provides a printable representation of | 135 boolean. Optional `condrepr` provides a printable representation of |
136 the given `condition`. | 136 the given `condition`. |
137 | 137 |
138 This is part of the mandatory API for smartset.""" | 138 This is part of the mandatory API for smartset.""" |
139 # builtin cannot be cached. but do not needs to | 139 # builtin cannot be cached. but do not needs to |
140 if cache and util.safehasattr(condition, '__code__'): | 140 if cache and hasattr(condition, '__code__'): |
141 condition = util.cachefunc(condition) | 141 condition = util.cachefunc(condition) |
142 return filteredset(self, condition, condrepr) | 142 return filteredset(self, condition, condrepr) |
143 | 143 |
144 def slice(self, start, stop): | 144 def slice(self, start, stop): |
145 """Return new smartset that contains selected elements from this set""" | 145 """Return new smartset that contains selected elements from this set""" |
1125 in self. Therefore `self & other = other`. | 1125 in self. Therefore `self & other = other`. |
1126 | 1126 |
1127 This boldly assumes the other contains valid revs only. | 1127 This boldly assumes the other contains valid revs only. |
1128 """ | 1128 """ |
1129 # other not a smartset, make is so | 1129 # other not a smartset, make is so |
1130 if not util.safehasattr(other, 'isascending'): | 1130 if not hasattr(other, 'isascending'): |
1131 # filter out hidden revision | 1131 # filter out hidden revision |
1132 # (this boldly assumes all smartset are pure) | 1132 # (this boldly assumes all smartset are pure) |
1133 # | 1133 # |
1134 # `other` was used with "&", let's assume this is a set like | 1134 # `other` was used with "&", let's assume this is a set like |
1135 # object. | 1135 # object. |