[PATCH] debugdeltachain: cleanup the double call to _slicechunk

Paul Morelle paul.morelle at octobus.net
Fri Jan 19 07:48:35 UTC 2018


# HG changeset patch
# User Paul Morelle <paul.morelle at octobus.net>
# Date 1516347322 -3600
#      Fri Jan 19 08:35:22 2018 +0100
# Node ID ce3b9d44cbf7de6fa0faad42442797cee9b337c8
# Parent  45b678bf3a787085d56fad5bee494e0c160aa120
# EXP-Topic debug-sparse-read
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ce3b9d44cbf7
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 -r 45b678bf3a78 -r ce3b9d44cbf7 mercurial/debugcommands.py
--- a/mercurial/debugcommands.py	Wed Jan 17 17:07:55 2018 +0100
+++ b/mercurial/debugcommands.py	Fri Jan 19 08:35:22 2018 +0100
@@ -684,7 +684,10 @@
         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 @@
 
             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,


More information about the Mercurial-devel mailing list