Patchwork [STABLE] debugrevlog: fix average size computation for empty data (issue6167)

login
register
mail settings
Submitter Pierre-Yves David
Date July 2, 2019, 9:01 a.m.
Message ID <9577ba917f59da7bd14c.1562058081@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/40741/
State Accepted
Headers show

Comments

Pierre-Yves David - July 2, 2019, 9:01 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1562057609 -7200
#      Tue Jul 02 10:53:29 2019 +0200
# Branch stable
# Node ID 9577ba917f59da7bd14c8d9d0e1f03545f5a8e83
# Parent  2c27b7fadcd3afabdcd9f72a6984166a8f6e39f4
# EXP-Topic issue6167
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 9577ba917f59
debugrevlog: fix average size computation for empty data (issue6167)

If the file has no full snapshot (eg: was always empty), `hg debugrevlog` would
fails when trying to compute their average size.
Pulkit Goyal - July 2, 2019, 10:42 p.m.
On Tue, Jul 2, 2019 at 12:09 PM Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1562057609 -7200
> #      Tue Jul 02 10:53:29 2019 +0200
> # Branch stable
> # Node ID 9577ba917f59da7bd14c8d9d0e1f03545f5a8e83
> # Parent  2c27b7fadcd3afabdcd9f72a6984166a8f6e39f4
> # EXP-Topic issue6167
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> 9577ba917f59
> debugrevlog: fix average size computation for empty data (issue6167)
>
> If the file has no full snapshot (eg: was always empty), `hg debugrevlog`
> would
> fails when trying to compute their average size.
>

Queued for stable, many thanks!

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2274,7 +2274,10 @@  def debugrevlog(ui, repo, file_=None, **
     totalrawsize = datasize[2]
     datasize[2] /= numrevs
     fulltotal = fullsize[2]
-    fullsize[2] /= numfull
+    if numfull == 0:
+        fullsize[2] = 0
+    else:
+        fullsize[2] /= numfull
     semitotal = semisize[2]
     snaptotal = {}
     if numsemi > 0: