diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -587,11 +587,22 @@ def debugdeltachain(ui, repo, file_=None the delta chain for this revision :``extraratio``: extradist divided by chainsize; another representation of how much unrelated data is needed to load this delta chain + + If the repository is configured to use the sparse read, additional keywords + are available: + + :``readsize``: total size of data read from the disk for a revision + (sum of the sizes of all the blocks) + :``largestblock``: size of the largest block of data read from the disk + :``readdensity``: density of useful bytes in the data read from the disk + + The sparse read can be enabled with experimental.sparse-read = True """ opts = pycompat.byteskwargs(opts) r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts) index = r.index generaldelta = r.version & revlog.FLAG_GENERALDELTA + withsparseread = getattr(r, '_withsparseread', False) def revinfo(rev): e = index[rev] @@ -627,15 +638,20 @@ def debugdeltachain(ui, repo, file_=None fm.plain(' rev chain# chainlen prev delta ' 'size rawsize chainsize ratio lindist extradist ' - 'extraratio\n') + 'extraratio') + if withsparseread: + fm.plain(' readsize largestblk rddensity') + fm.plain('\n') chainbases = {} for rev in r: comp, uncomp, deltatype, chain, chainsize = revinfo(rev) chainbase = chain[0] chainid = chainbases.setdefault(chainbase, len(chainbases) + 1) - basestart = r.start(chainbase) - revstart = r.start(rev) + start = r.start + length = r.length + basestart = start(chainbase) + revstart = start(rev) lineardist = revstart + comp - basestart extradist = lineardist - chainsize try: @@ -650,7 +666,7 @@ def debugdeltachain(ui, repo, file_=None fm.write('rev chainid chainlen prevrev deltatype compsize ' 'uncompsize chainsize chainratio lindist extradist ' 'extraratio', - '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n', + '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f', rev, chainid, len(chain), prevrev, deltatype, comp, uncomp, chainsize, chainratio, lineardist, extradist, extraratio, @@ -659,6 +675,26 @@ def debugdeltachain(ui, repo, file_=None uncompsize=uncomp, chainsize=chainsize, chainratio=chainratio, lindist=lineardist, extradist=extradist, extraratio=extraratio) + if withsparseread: + readsize = 0 + largestblock = 0 + for revschunk in revlog._slicechunk(r, chain): + blkend = start(revschunk[-1]) + length(revschunk[-1]) + blksize = blkend - start(revschunk[0]) + + readsize += blksize + if largestblock < blksize: + largestblock = blksize + + readdensity = float(chainsize) / float(readsize) + + fm.write('readsize largestblock readdensity', + ' %10d %10d %9.5f', + readsize, largestblock, readdensity, + readsize=readsize, largestblock=largestblock, + readdensity=readdensity) + + fm.plain('\n') fm.end() diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t --- a/tests/test-debugcommands.t +++ b/tests/test-debugcommands.t @@ -77,6 +77,40 @@ debugdelta chain basic output } ] +debugdelta chain with sparse read enabled + + $ cat >> $HGRCPATH < [experimental] + > sparse-read = True + > EOF + $ hg debugdeltachain -m + rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity + 0 1 1 -1 base 44 43 44 1.02326 44 0 0.00000 44 44 1.00000 + + $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen} {readsize} {largestblock} {readdensity}\n' + 0 1 1 44 44 1.0 + + $ hg debugdeltachain -m -Tjson + [ + { + "chainid": 1, + "chainlen": 1, + "chainratio": 1.02325581395, + "chainsize": 44, + "compsize": 44, + "deltatype": "base", + "extradist": 0, + "extraratio": 0.0, + "largestblock": 44, + "lindist": 44, + "prevrev": -1, + "readdensity": 1.0, + "readsize": 44, + "rev": 0, + "uncompsize": 43 + } + ] + Test max chain len $ cat >> $HGRCPATH << EOF > [format]