commands: use `iter(callable, sentinel)` instead of while True
authorAugie Fackler <augie@google.com>
Fri, 05 Aug 2016 14:00:08 -0400
changeset 29725 cbeb2cb578b1
parent 29724 4e7be6e33269
child 29726 160c829dd5d0
commands: use `iter(callable, sentinel)` instead of while True This is functionally equivalent, but is a little more concise.
mercurial/commands.py
--- a/mercurial/commands.py	Fri Aug 05 13:59:58 2016 -0400
+++ b/mercurial/commands.py	Fri Aug 05 14:00:08 2016 -0400
@@ -2102,10 +2102,7 @@
         def showchunks(named):
             ui.write("\n%s%s\n" % (indent_string, named))
             chain = None
-            while True:
-                chunkdata = gen.deltachunk(chain)
-                if not chunkdata:
-                    break
+            for chunkdata in iter(lambda: gen.deltachunk(chain), {}):
                 node = chunkdata['node']
                 p1 = chunkdata['p1']
                 p2 = chunkdata['p2']
@@ -2121,10 +2118,7 @@
         showchunks("changelog")
         chunkdata = gen.manifestheader()
         showchunks("manifest")
-        while True:
-            chunkdata = gen.filelogheader()
-            if not chunkdata:
-                break
+        for chunkdata in iter(gen.filelogheader, {}):
             fname = chunkdata['filename']
             showchunks(fname)
     else:
@@ -2132,10 +2126,7 @@
             raise error.Abort(_('use debugbundle2 for this file'))
         chunkdata = gen.changelogheader()
         chain = None
-        while True:
-            chunkdata = gen.deltachunk(chain)
-            if not chunkdata:
-                break
+        for chunkdata in iter(lambda: gen.deltachunk(chain), {}):
             node = chunkdata['node']
             ui.write("%s%s\n" % (indent_string, hex(node)))
             chain = node