[PATCH 5 of 9] sshserver: use `iter(callable, sentinel)` instead of while True

Augie Fackler raf at durin42.com
Sat Aug 6 11:02:35 EDT 2016


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1470420030 14400
#      Fri Aug 05 14:00:30 2016 -0400
# Node ID 07c773056e724ba6e1e753635909e968026cffb3
# Parent  5fbdb186660f4c93905498e4a1a5f71d7a0cd7ec
sshserver: use `iter(callable, sentinel)` instead of while True

This is functionally equivalent, but is a little more concise.

diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py
--- a/mercurial/sshserver.py
+++ b/mercurial/sshserver.py
@@ -69,11 +69,7 @@ class sshserver(wireproto.abstractserver
         pass
 
     def groupchunks(self, changegroup):
-        while True:
-            d = changegroup.read(4096)
-            if not d:
-                break
-            yield d
+        return iter(lambda: changegroup.read(4096), '')
 
     def sendresponse(self, v):
         self.fout.write("%d\n" % len(v))


More information about the Mercurial-devel mailing list