Mercurial > hg
changeset 25169:7855d1f5f152
getlogrevs: rewrite a loop to get read of try/except
Get rid of the 'except StopIteration' abomination.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 18 May 2015 12:18:00 -0500 |
parents | 4dfd4d3b9b93 |
children | c69f4f7fe01a |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 3 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Mon May 18 12:17:08 2015 -0500 +++ b/mercurial/cmdutil.py Mon May 18 12:18:00 2015 -0500 @@ -2127,15 +2127,11 @@ if not opts.get('rev'): revs.sort(reverse=True) if limit is not None: - count = 0 limitedrevs = [] - it = iter(revs) - while count < limit: - try: - limitedrevs.append(it.next()) - except (StopIteration): + for idx, r in enumerate(revs): + if limit <= idx: break - count += 1 + limitedrevs.append(r) revs = revset.baseset(limitedrevs) return revs, expr, filematcher