[PATCH] debugdeltachain: output information about sparse read if enabled

Yuya Nishihara yuya at tcha.org
Thu Nov 9 07:53:13 EST 2017


On Wed, 08 Nov 2017 21:12:57 +0100, Paul Morelle wrote:
> # HG changeset patch
> # User Paul Morelle <paul.morelle at octobus.net>
> # Date 1509002829 -7200
> #      Thu Oct 26 09:27:09 2017 +0200
> # Node ID 13a6c881be35e7651a12f8c3442abfade2b77c88
> # Parent  602c168c0207c443ac61f7a7c727b31cfb0b86ad
> # EXP-Topic debugdeltachain
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 13a6c881be35
> debugdeltachain: output information about sparse read if enabled

Looks good, but check-code failed.

And can you add some tests?

> +        fmargs = (rev, chainid, len(chain), prevrev, deltatype, comp,
> +                  uncomp, chainsize, chainratio, lineardist, extradist,
> +                  extraratio)
> +        fmkwargs = dict(rev=rev, chainid=chainid, chainlen=len(chain),
> +                        prevrev=prevrev, deltatype=deltatype, compsize=comp,
> +                        uncompsize=uncomp, chainsize=chainsize,
> +                        chainratio=chainratio, lindist=lineardist,
> +                        extradist=extradist, extraratio=extraratio)

test-check-code.t says hi.

+  mercurial/debugcommands.py:675:
+   >         fmkwargs = dict(rev=rev, chainid=chainid, chainlen=len(chain),
+   dict() is different in Py2 and 3 and is slower than {}

FWIW, I don't know what's the purpose of this fmkwargs dict.

> +        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)
> +
> +            fmargs += (readsize, largestblock, readdensity)
> +            fmkwargs.update(readsize=readsize, largestblock=largestblock,
> +                            readdensity=readdensity)
> +
>          fm.startitem()
> -        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',
> -                 rev, chainid, len(chain), prevrev, deltatype, comp,
> -                 uncomp, chainsize, chainratio, lineardist, extradist,
> -                 extraratio,
> -                 rev=rev, chainid=chainid, chainlen=len(chain),
> -                 prevrev=prevrev, deltatype=deltatype, compsize=comp,
> -                 uncompsize=uncomp, chainsize=chainsize,
> -                 chainratio=chainratio, lindist=lineardist,
> -                 extradist=extradist, extraratio=extraratio)
> +        fm.write(fmfields, fmformats + '\n', *fmargs, **fmkwargs)

Alternatively, this could be split to two write() calls.

  fm.write(...)
  if withsparseread:
      fm.write(...)
  fm.plain('\n')


More information about the Mercurial-devel mailing list