Mercurial > hg-stable
changeset 25143:91c49621b2b8
_revancestors: use 'next' to remove the verbose try except clauses
The 'next()' built-in can return a default value, making the final iteration
case simpler and clearer.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sun, 17 May 2015 17:54:58 -0700 |
parents | 24140873ca4c |
children | 81a395447b34 |
files | mercurial/revset.py |
diffstat | 1 files changed, 5 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Sun May 17 17:47:42 2015 -0700 +++ b/mercurial/revset.py Sun May 17 17:54:58 2015 -0700 @@ -28,21 +28,18 @@ revs.sort(reverse=True) irevs = iter(revs) h = [] - try: - inputrev = irevs.next() + + inputrev = next(irevs, None) + if inputrev is not None: heapq.heappush(h, -inputrev) - except StopIteration: - return seen = set() while h: current = -heapq.heappop(h) if current == inputrev: - try: - inputrev = irevs.next() + inputrev = next(irevs, None) + if inputrev is not None: heapq.heappush(h, -inputrev) - except StopIteration: - pass if current not in seen: seen.add(current) yield current