changeset 29724:4e7be6e33269

changegroup: use `iter(callable, sentinel)` instead of while True This is functionally equivalent, but is a little more concise.
author Augie Fackler <augie@google.com>
date Fri, 05 Aug 2016 13:59:58 -0400
parents 91b2f2176395
children cbeb2cb578b1
files mercurial/changegroup.py
diffstat 1 files changed, 2 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Wed Jul 27 21:44:49 2016 +0900
+++ b/mercurial/changegroup.py	Fri Aug 05 13:59:58 2016 -0400
@@ -475,10 +475,7 @@
     def _unpackmanifests(self, repo, revmap, trp, prog, numchanges):
         super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog,
                                                   numchanges)
-        while True:
-            chunkdata = self.filelogheader()
-            if not chunkdata:
-                break
+        for chunkdata in iter(self.filelogheader, {}):
             # If we get here, there are directory manifests in the changegroup
             d = chunkdata["filename"]
             repo.ui.debug("adding %s revisions\n" % d)
@@ -1012,10 +1009,7 @@
 def _addchangegroupfiles(repo, source, revmap, trp, expectedfiles, needfiles):
     revisions = 0
     files = 0
-    while True:
-        chunkdata = source.filelogheader()
-        if not chunkdata:
-            break
+    for chunkdata in iter(source.filelogheader, {}):
         files += 1
         f = chunkdata["filename"]
         repo.ui.debug("adding %s revisions\n" % f)