Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webcommands.py @ 52669:e627cc25b6f3
pyupgrade: rewrite `yield` statements in a loop to `yield from`
This is the `legacy` fixer in `pyupgrade`, with the `yield` statement yielding
loop commented back in. This seems to help pytype in some cases, and hurt it in
others. But that can be manually fixed later.
Note that it's possibly buggy in that it aggressively changed `import-checker.py`
to `yield from 'fcntl', 'grp', 'pwd', 'select', 'termios': # Unix only`, which
is invalid syntax. Possibly it needed help from the token fixer that I've
disabled locally (because that wants to make a bunch of unrelated changes).
Just change those few places to yield from a list, to avoid having to constantly
revert that.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 05 Jan 2025 22:26:16 -0500 |
parents | dc36535a5edc |
children |
comparison
equal
deleted
inserted
replaced
52668:5cc8deb96b48 | 52669:e627cc25b6f3 |
---|---|
232 l = [] | 232 l = [] |
233 for j in cl.revs(max(0, i - 99), i): | 233 for j in cl.revs(max(0, i - 99), i): |
234 ctx = web.repo[j] | 234 ctx = web.repo[j] |
235 l.append(ctx) | 235 l.append(ctx) |
236 l.reverse() | 236 l.reverse() |
237 for e in l: | 237 yield from l |
238 yield e | |
239 | 238 |
240 for ctx in revgen(): | 239 for ctx in revgen(): |
241 miss = 0 | 240 miss = 0 |
242 for q in qw: | 241 for q in qw: |
243 if not ( | 242 if not ( |
423 def changelist(maxcount): | 422 def changelist(maxcount): |
424 revs = [] | 423 revs = [] |
425 if pos != -1: | 424 if pos != -1: |
426 revs = web.repo.changelog.revs(pos, 0) | 425 revs = web.repo.changelog.revs(pos, 0) |
427 | 426 |
428 for entry in webutil.changelistentries(web, revs, maxcount, parity): | 427 yield from webutil.changelistentries(web, revs, maxcount, parity) |
429 yield entry | |
430 | 428 |
431 if shortlog: | 429 if shortlog: |
432 revcount = web.maxshortchanges | 430 revcount = web.maxshortchanges |
433 else: | 431 else: |
434 revcount = web.maxchanges | 432 revcount = web.maxchanges |
796 ctx = web.repo[i] | 794 ctx = web.repo[i] |
797 lm = webutil.commonentry(web.repo, ctx) | 795 lm = webutil.commonentry(web.repo, ctx) |
798 lm[b'parity'] = next(parity) | 796 lm[b'parity'] = next(parity) |
799 l.append(lm) | 797 l.append(lm) |
800 | 798 |
801 for entry in reversed(l): | 799 yield from reversed(l) |
802 yield entry | |
803 | 800 |
804 tip = web.repo[b'tip'] | 801 tip = web.repo[b'tip'] |
805 count = len(web.repo) | 802 count = len(web.repo) |
806 start = max(0, count - web.maxchanges) | 803 start = max(0, count - web.maxchanges) |
807 end = min(count, start + web.maxchanges) | 804 end = min(count, start + web.maxchanges) |