bundlerepo: use for loop over iterator instead of while True
authorAugie Fackler <augie@google.com>
Fri, 05 Aug 2016 13:09:24 -0400
changeset 29710 0839c8d34d78
parent 29709 b9ee2a1c4e9c
child 29711 ac5f6b11aa91
bundlerepo: use for loop over iterator instead of while True The iter() builtin has a neat pattern where you give it a callable of no arguments and a sentinel value, and you can then loop over the function calls like a normal iterator. This cleans up the code a little.
mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py	Fri Aug 05 12:47:03 2016 -0400
+++ b/mercurial/bundlerepo.py	Fri Aug 05 13:09:24 2016 -0400
@@ -351,10 +351,7 @@
     def file(self, f):
         if not self.bundlefilespos:
             self.bundle.seek(self.filestart)
-            while True:
-                chunkdata = self.bundle.filelogheader()
-                if not chunkdata:
-                    break
+            for chunkdata in iter(self.bundle.filelogheader, {}):
                 fname = chunkdata['filename']
                 self.bundlefilespos[fname] = self.bundle.tell()
                 while True: