diff mercurial/bundle2.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 5cc8deb96b48
children 4cb75772818d
line wrap: on
line diff
--- a/mercurial/bundle2.py	Sun Jan 05 22:23:31 2025 -0500
+++ b/mercurial/bundle2.py	Sun Jan 05 22:26:16 2025 -0500
@@ -753,10 +753,9 @@
         yield _pack(_fstreamparamsize, len(param))
         if param:
             yield param
-        for chunk in self._compengine.compressstream(
+        yield from self._compengine.compressstream(
             self._getcorechunk(), self._compopts
-        ):
-            yield chunk
+        )
 
     def _paramchunk(self):
         """return a encoded version of all stream parameters"""
@@ -776,8 +775,7 @@
         outdebug(self.ui, b'start of parts')
         for part in self._parts:
             outdebug(self.ui, b'bundle part: "%s"' % part.type)
-            for chunk in part.getchunks(ui=self.ui):
-                yield chunk
+            yield from part.getchunks(ui=self.ui)
         outdebug(self.ui, b'end of bundle')
         yield _pack(_fpartheadersize, 0)
 
@@ -1861,10 +1859,8 @@
             utf8branch = encoding.fromlocal(branch)
             yield rbcstruct.pack(len(utf8branch), len(nodes), len(closed))
             yield utf8branch
-            for n in sorted(nodes):
-                yield n
-            for n in sorted(closed):
-                yield n
+            yield from sorted(nodes)
+            yield from sorted(closed)
 
     bundler.newpart(b'cache:rev-branch-cache', data=generate(), mandatory=False)
 
@@ -2033,8 +2029,7 @@
 
         def chunkiter():
             yield header
-            for chunk in compengine.compressstream(cg.getchunks(), compopts):
-                yield chunk
+            yield from compengine.compressstream(cg.getchunks(), compopts)
 
         chunkiter = chunkiter()