On Fri, 29 Jun 2018 18:17:33 +0200, Paul Morelle wrote: > # HG changeset patch > # User Paul Morelle <paul.more...@octobus.net> > # Date 1529597997 -7200 > # Thu Jun 21 18:19:57 2018 +0200 > # Node ID 9b9cb7abec13ed745c14c3a1357ee2c2dd55c4b5 > # Parent 5d88fd1bc2af0af02129f0ad2b267d778349d95a > # EXP-Topic debugdeltachain-divbyzero > # Available At https://bitbucket.org/octobus/mercurial-devel/ > # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r > 9b9cb7abec13 > debugdeltachain: avoid division by zero when a chain is empty > > The two ratios chainratio and extraratio are computed using dividers > that may be zero when the file is empty. > As the denominators are integers, the limit of the ratio "just before zero" is > the numerator value itself. > If the numerator itself is zero, the ratio value is still meaningful: in both > cases, a "good" value is a low ratio, and a size of zero is the optimal case. > > diff -r 5d88fd1bc2af -r 9b9cb7abec13 mercurial/debugcommands.py > --- a/mercurial/debugcommands.py Sat Jun 16 23:26:40 2018 +0900 > +++ b/mercurial/debugcommands.py Thu Jun 21 18:19:57 2018 +0200 > @@ -678,8 +678,15 @@ > except IndexError: > prevrev = -1 > > - chainratio = float(chainsize) / float(uncomp) > - extraratio = float(extradist) / float(chainsize) > + if uncomp != 0: > + chainratio = float(chainsize) / float(uncomp) > + else: > + chainratio = chainsize > + > + if chainsize != 0: > + extraratio = float(extradist) / float(chainsize) > + else: > + extraratio = extradist
Seems fine though I don't think the result is 100% correct. Can you add a test? _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel