changegroup: use `iter(callable, sentinel)` instead of while True
authorAugie Fackler <augie@google.com>
Fri, 05 Aug 2016 13:59:58 -0400
changeset 29724 4e7be6e33269
parent 29723 91b2f2176395
child 29725 cbeb2cb578b1
changegroup: use `iter(callable, sentinel)` instead of while True This is functionally equivalent, but is a little more concise.
mercurial/changegroup.py
--- 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)