# HG changeset patch # User Paul Morelle # Date 2018-01-19 07:35:22 # Node ID 22a877215ea12953d2eb03c735d3e322cd2333bb # Parent 05c70675e5b9cd89c5265ce79864c11be9b9a5ed debugdeltachain: cleanup the double call to _slicechunk Follow-up to Yuya's review on 43154a76f3927c4f0c8c6b02be80f0069c7d8fdb: > Nit: hasattr() isn't necessary. revlog._slicechunk() is used in the previous > block. hasattr() isn't necessary indeed, as we are protected by the withsparseread option, which was introduced at the same time as revlog._slicechunk, in e2ad93bcc084b97c48f54c179365376edb702858. And, as Yuya noticed, _slicechunk could be called only once. diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -684,7 +684,10 @@ def debugdeltachain(ui, repo, file_=None if withsparseread: readsize = 0 largestblock = 0 + srchunks = 0 + for revschunk in revlog._slicechunk(r, chain): + srchunks += 1 blkend = start(revschunk[-1]) + length(revschunk[-1]) blksize = blkend - start(revschunk[0]) @@ -694,12 +697,6 @@ def debugdeltachain(ui, repo, file_=None readdensity = float(chainsize) / float(readsize) - if util.safehasattr(revlog, '_slicechunk'): - revchunks = tuple(revlog._slicechunk(r, chain)) - else: - revchunks = (chain,) - srchunks = len(revchunks) - fm.write('readsize largestblock readdensity srchunks', ' %10d %10d %9.5f %8d', readsize, largestblock, readdensity, srchunks,