# HG changeset patch # User Augie Fackler # Date 2016-08-05 17:59:58 # Node ID 4e7be6e3326903f77be0f605a269e42aaf19bf42 # Parent 91b2f21763955063b994b07a1060305e0fe93031 changegroup: use `iter(callable, sentinel)` instead of while True This is functionally equivalent, but is a little more concise. diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -475,10 +475,7 @@ class cg3unpacker(cg2unpacker): 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 changegroup(repo, basenodes, source) 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)