Patchwork [8,of,8,STABLE] debugrevlog: handle no revs

login
register
mail settings
Submitter timeless@mozdev.org
Date Feb. 1, 2016, 7:29 a.m.
Message ID <8e74d29278f9379ddb01.1454311759@waste.org>
Download mbox | patch
Permalink /patch/12921/
State Changes Requested
Headers show

Comments

timeless@mozdev.org - Feb. 1, 2016, 7:29 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1454273865 0
#      Sun Jan 31 20:57:45 2016 +0000
# Branch stable
# Node ID 8e74d29278f9379ddb01794d43dca2f515fde93e
# Parent  f45868741d783847ab04531df73eff5d6c4b2304
debugrevlog: handle no revs
Pierre-Yves David - Feb. 1, 2016, 12:20 p.m.
On 02/01/2016 07:29 AM, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1454273865 0
> #      Sun Jan 31 20:57:45 2016 +0000
> # Branch stable
> # Node ID 8e74d29278f9379ddb01794d43dca2f515fde93e
> # Parent  f45868741d783847ab04531df73eff5d6c4b2304
> debugrevlog: handle no revs

What was broken ?

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3283,18 +3283,19 @@ 
     numdeltas = numrevs - numfull
     numoprev = numprev - nump1prev - nump2prev
     totalrawsize = datasize[2]
-    datasize[2] /= numrevs
-    fulltotal = fullsize[2]
-    fullsize[2] /= numfull
-    deltatotal = deltasize[2]
-    if numrevs - numfull > 0:
-        deltasize[2] /= numrevs - numfull
-    totalsize = fulltotal + deltatotal
-    avgchainlen = sum(chainlengths) / numrevs
-    maxchainlen = max(chainlengths)
-    compratio = 1
-    if totalsize:
-        compratio = totalrawsize / totalsize
+    if numrevs:
+        datasize[2] /= numrevs
+        fulltotal = fullsize[2]
+        fullsize[2] /= numfull
+        deltatotal = deltasize[2]
+        if numdeltas > 0:
+            deltasize[2] /= numdeltas
+        totalsize = fulltotal + deltatotal
+        avgchainlen = sum(chainlengths) / numrevs
+        maxchainlen = max(chainlengths)
+        compratio = 1
+        if totalsize:
+            compratio = totalrawsize / totalsize
 
     basedfmtstr = '%%%dd\n'
     basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
@@ -3313,19 +3314,21 @@ 
     ui.write(('format : %d\n') % format)
     ui.write(('flags  : %s\n') % ', '.join(flags))
 
-    ui.write('\n')
-    if totalrawsize:
+    if numrevs:
+        ui.write('\n')
+        if totalrawsize:
             fmt = pcfmtstr(totalsize)
             fmt2 = dfmtstr(totalsize)
-    else:
+        else:
             fmt = pcfmtstr(numrevs)
             fmt2 = dfmtstr(numrevs)
-    ui.write(('revisions     : ') + fmt2 % numrevs)
-    ui.write(('    merges    : ') + fmt % pcfmt(nummerges, numrevs))
-    ui.write(('    normal    : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
-    ui.write(('revisions     : ') + fmt2 % numrevs)
-    ui.write(('    full      : ') + fmt % pcfmt(numfull, numrevs))
-    ui.write(('    deltas    : ') + fmt % pcfmt(numdeltas, numrevs))
+        ui.write(('revisions     : ') + fmt2 % numrevs)
+        ui.write(('    merges    : ') + fmt % pcfmt(nummerges, numrevs))
+        ui.write(('    normal    : ') + fmt %
+                 pcfmt(numrevs - nummerges, numrevs))
+        ui.write(('revisions     : ') + fmt2 % numrevs)
+        ui.write(('    full      : ') + fmt % pcfmt(numfull, numrevs))
+        ui.write(('    deltas    : ') + fmt % pcfmt(numdeltas, numrevs))
     if totalrawsize:
         ui.write(('revision size : ') + fmt2 % totalsize)
         ui.write(('    full      : ') + fmt % pcfmt(fulltotal, totalsize))
diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t
--- a/tests/test-debugcommands.t
+++ b/tests/test-debugcommands.t
@@ -20,11 +20,32 @@ 
   
   (use "hg debugrevlog -h" to show more help)
   [255]
+  $ hg debugrevlog -c
+  format : 1
+  flags  : inline
+  
+  uncompressed data size (min/max/avg) : 0 / 0 / 0
+  full revision size (min/max/avg)     : 0 / 0 / 0
+  delta size (min/max/avg)             : 0 / 0 / 0
+  $ hg debugrevlog -m
+  format : 1
+  flags  : inline, generaldelta
+  
+  uncompressed data size (min/max/avg) : 0 / 0 / 0
+  full revision size (min/max/avg)     : 0 / 0 / 0
+  delta size (min/max/avg)             : 0 / 0 / 0
   $ hg debugrevlog -c -d
   # rev p1rev p2rev start   end deltastart base   p1   p2 rawsize totalsize compression heads chainlen
   $ hg debugrevlog -m -d
   # rev p1rev p2rev start   end deltastart base   p1   p2 rawsize totalsize compression heads chainlen
   $ hg commit --config ui.allowemptycommit=True -m 'empty'
+  $ hg debugrevlog -m
+  format : 1
+  flags  : inline, generaldelta
+  
+  uncompressed data size (min/max/avg) : 0 / 0 / 0
+  full revision size (min/max/avg)     : 0 / 0 / 0
+  delta size (min/max/avg)             : 0 / 0 / 0
   $ hg debugrevlog -m -d
   # rev p1rev p2rev start   end deltastart base   p1   p2 rawsize totalsize compression heads chainlen
   $ hg debugrevlog -c -d