[PATCH] debugrevlog: cope with empty revlog files
Anton Shestakov
engored at ya.ru
Fri Oct 23 11:33:03 CDT 2015
24.10.2015, 00:08, "Sean Farley" <sean at farley.io>:
> Augie Fackler <raf at durin42.com> writes:
>
>> # HG changeset patch
>> # User Augie Fackler <augie at google.com>
>> # Date 1445612693 14400
>> # Fri Oct 23 11:04:53 2015 -0400
>> # Branch stable
>> # Node ID fc066f62eac58937b40948c850cc18633d43f2cb
>> # Parent 27683c63f44cb58d02df2d4dc16f5ba3348d394c
>> debugrevlog: cope with empty revlog files
>>
>> I have no idea where it came from, but my clone of Mercurial has an
>> empty filelog for `contrib/hgfixes/__init__.py` - it's *valid*, just
>> contains no nodes. Without this change, debugrevlog crashes with a
>> zero division error.
>>
>> diff --git a/mercurial/commands.py b/mercurial/commands.py
>> --- a/mercurial/commands.py
>> +++ b/mercurial/commands.py
>> @@ -3037,7 +3037,10 @@ def debugrevlog(ui, repo, file_=None, **
>> totalsize = fulltotal + deltatotal
>> avgchainlen = sum(chainlengths) / numrevs
>> maxchainlen = max(chainlengths)
>> - compratio = totalrawsize / totalsize
>> + if totalsize:
>> + compratio = totalrawsize / totalsize
>> + else:
>> + compratio = 1
>
> Minor nit: can we write this as
>
> comratio = 1
> if totalsize:
> compratio = totalrawsize / totalsize
Even smaller nit: could be spelled as
compratio = totalrawsize / totalsize if totalsize else 1
(I mean we're bikeshedding anyway, right?)
More information about the Mercurial-devel
mailing list