Mercurial > hg
changeset 29727:0dbd788a2dfd
sshpeer: 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 14:00:22 -0400 |
parents | 160c829dd5d0 |
children | 1a29db79a98d |
files | mercurial/sshpeer.py |
diffstat | 1 files changed, 3 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/sshpeer.py Fri Aug 05 14:00:14 2016 -0400 +++ b/mercurial/sshpeer.py Fri Aug 05 14:00:22 2016 -0400 @@ -292,10 +292,7 @@ r = self._call(cmd, **args) if r: return '', r - while True: - d = fp.read(4096) - if not d: - break + for d in iter(lambda: fp.read(4096), ''): self._send(d) self._send("", flush=True) r = self._recv() @@ -308,10 +305,7 @@ if r: # XXX needs to be made better raise error.Abort(_('unexpected remote reply: %s') % r) - while True: - d = fp.read(4096) - if not d: - break + for d in iter(lambda: fp.read(4096), ''): self._send(d) self._send("", flush=True) return self.pipei @@ -353,10 +347,7 @@ d = self._call("addchangegroup") if d: self._abort(error.RepoError(_("push refused: %s") % d)) - while True: - d = cg.read(4096) - if not d: - break + for d in iter(lambda: cg.read(4096), ''): self.pipeo.write(d) self.readerr()