Patchwork [9,of,9] revlog: use `iter(callable, sentinel)` instead of while True

login
register
mail settings
Submitter Augie Fackler
Date Aug. 6, 2016, 3:02 p.m.
Message ID <8020b63576c0d90c9c1d.1470495759@imladris.local>
Download mbox | patch
Permalink /patch/16163/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 6, 2016, 3:02 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1470425702 14400
#      Fri Aug 05 15:35:02 2016 -0400
# Node ID 8020b63576c0d90c9c1d81e36c0b36fd2083d18f
# Parent  a5dd8e8ff9e492b2d862191a94654f82f7efe509
revlog: use `iter(callable, sentinel)` instead of while True

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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1585,10 +1585,7 @@  class revlog(object):
         try:
             # loop through our set of deltas
             chain = None
-            while True:
-                chunkdata = cg.deltachunk(chain)
-                if not chunkdata:
-                    break
+            for chunkdata in iter(lambda: cg.deltachunk(chain), {}):
                 node = chunkdata['node']
                 p1 = chunkdata['p1']
                 p2 = chunkdata['p2']