Mercurial > hg
changeset 29725:cbeb2cb578b1
commands: 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:08 -0400 |
parents | 4e7be6e33269 |
children | 160c829dd5d0 |
files | mercurial/commands.py |
diffstat | 1 files changed, 3 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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