comparison mercurial/streamclone.py @ 52644: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 24ee91ba9aa8
children 279e217d6041
comparison
equal deleted inserted replaced
52643:5cc8deb96b48 52644:e627cc25b6f3
301 # trusted by the local repo) and expensive 301 # trusted by the local repo) and expensive
302 with svfs(name, b'rb', auditpath=False) as fp: 302 with svfs(name, b'rb', auditpath=False) as fp:
303 if size <= 65536: 303 if size <= 65536:
304 yield fp.read(size) 304 yield fp.read(size)
305 else: 305 else:
306 for chunk in util.filechunkiter(fp, limit=size): 306 yield from util.filechunkiter(fp, limit=size)
307 yield chunk
308 307
309 return len(entries), total_bytes, emitrevlogdata() 308 return len(entries), total_bytes, emitrevlogdata()
310 309
311 310
312 def generatev1wireproto(repo): 311 def generatev1wireproto(repo):
331 return 330 return
332 331
333 # Indicates successful response. 332 # Indicates successful response.
334 yield b'0\n' 333 yield b'0\n'
335 yield b'%d %d\n' % (filecount, bytecount) 334 yield b'%d %d\n' % (filecount, bytecount)
336 for chunk in it: 335 yield from it
337 yield chunk
338 336
339 337
340 def generatebundlev1(repo, compression=b'UN'): 338 def generatebundlev1(repo, compression=b'UN'):
341 """Emit content for version 1 of a stream clone bundle. 339 """Emit content for version 1 of a stream clone bundle.
342 340