[PATCH 1 of 9] changegroup: use `iter(callable, sentinel)` instead of while True
Augie Fackler
raf at durin42.com
Sat Aug 6 15:02:31 UTC 2016
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1470419998 14400
# Fri Aug 05 13:59:58 2016 -0400
# Node ID 84bc06986855488a7237adc057655baa1e3c3e09
# 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)
More information about the Mercurial-devel
mailing list