changeset 39153:9d6fab487c13

debugrevlog: display snapshot details per depth This help in understanding the final structure of build manifest. All data about snapshot (full and intermediate) are gathered into a sub-list for clarity. Since we do not produce such snapshots yet, the only thing changing in test output is the way the information is presented.
author Boris Feld <boris.feld@octobus.net>
date Wed, 15 Aug 2018 12:30:30 +0200
parents 3b1042cab4b4
children e0da43e2f71f
files mercurial/debugcommands.py tests/test-debugcommands.t
diffstat 2 files changed, 45 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Wed Aug 15 12:09:14 2018 +0200
+++ b/mercurial/debugcommands.py	Wed Aug 15 12:30:30 2018 +0200
@@ -2097,6 +2097,8 @@
     numfull = 0
     # intermediate snapshot against a prior snapshot
     numsemi = 0
+    # snapshot count per depth
+    numsnapdepth = collections.defaultdict(lambda: 0)
     # delta against previous revision
     numprev = 0
     # delta against first or second parent (not prev)
@@ -2118,6 +2120,8 @@
     datasize = [None, 0, 0]
     fullsize = [None, 0, 0]
     semisize = [None, 0, 0]
+    # snapshot count per depth
+    snapsizedepth = collections.defaultdict(lambda: [None, 0, 0])
     deltasize = [None, 0, 0]
     chunktypecounts = {}
     chunktypesizes = {}
@@ -2147,7 +2151,9 @@
                 numemptytext += 1
             else:
                 numfull += 1
+                numsnapdepth[0] += 1
                 addsize(size, fullsize)
+                addsize(size, snapsizedepth[0])
         else:
             chainlengths.append(chainlengths[delta] + 1)
             baseaddr = chainbases[delta]
@@ -2160,6 +2166,9 @@
             elif r.issnapshot(rev):
                 addsize(size, semisize)
                 numsemi += 1
+                depth = r.snapshotdepth(rev)
+                numsnapdepth[depth] += 1
+                addsize(size, snapsizedepth[depth])
             else:
                 addsize(size, deltasize)
                 if delta == rev - 1:
@@ -2204,8 +2213,13 @@
     fulltotal = fullsize[2]
     fullsize[2] /= numfull
     semitotal = semisize[2]
+    snaptotal = {}
     if 0 < numsemi:
         semisize[2] /= numsemi
+    for depth in snapsizedepth:
+        snaptotal[depth] = snapsizedepth[depth][2]
+        snapsizedepth[depth][2] /= numsnapdepth[depth]
+
     deltatotal = deltasize[2]
     if numdeltas > 0:
         deltasize[2] /= numdeltas
@@ -2246,12 +2260,17 @@
              + fmt % pcfmt(numemptytext, numemptytext + numemptydelta))
     ui.write(('                   delta : ')
              + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta))
-    ui.write(('    full      : ') + fmt % pcfmt(numfull, numrevs))
-    ui.write(('    inter     : ') + fmt % pcfmt(numsemi, numrevs))
+    ui.write(('    snapshot  : ') + fmt % pcfmt(numfull + numsemi, numrevs))
+    for depth in sorted(numsnapdepth):
+        ui.write(('      lvl-%-3d :       ' % depth)
+                 + fmt % pcfmt(numsnapdepth[depth], numrevs))
     ui.write(('    deltas    : ') + fmt % pcfmt(numdeltas, numrevs))
     ui.write(('revision size : ') + fmt2 % totalsize)
-    ui.write(('    full      : ') + fmt % pcfmt(fulltotal, totalsize))
-    ui.write(('    inter     : ') + fmt % pcfmt(semitotal, totalsize))
+    ui.write(('    snapshot  : ')
+             + fmt % pcfmt(fulltotal + semitotal, totalsize))
+    for depth in sorted(numsnapdepth):
+        ui.write(('      lvl-%-3d :       ' % depth)
+                 + fmt % pcfmt(snaptotal[depth], totalsize))
     ui.write(('    deltas    : ') + fmt % pcfmt(deltatotal, totalsize))
 
     def fmtchunktype(chunktype):
@@ -2285,6 +2304,13 @@
                  % tuple(datasize))
     ui.write(('full revision size (min/max/avg)     : %d / %d / %d\n')
              % tuple(fullsize))
+    ui.write(('inter-snapshot size (min/max/avg)    : %d / %d / %d\n')
+             % tuple(semisize))
+    for depth in sorted(snapsizedepth):
+        if depth == 0:
+            continue
+        ui.write(('    level-%-3d (min/max/avg)          : %d / %d / %d\n')
+                 % ((depth,) + tuple(snapsizedepth[depth])))
     ui.write(('delta size (min/max/avg)             : %d / %d / %d\n')
              % tuple(deltasize))
 
--- a/tests/test-debugcommands.t	Wed Aug 15 12:09:14 2018 +0200
+++ b/tests/test-debugcommands.t	Wed Aug 15 12:30:30 2018 +0200
@@ -26,12 +26,12 @@
       empty     :   0 ( 0.00%)
                      text  :   0 (100.00%)
                      delta :   0 (100.00%)
-      full      :   3 (100.00%)
-      inter     :   0 ( 0.00%)
+      snapshot  :   3 (100.00%)
+        lvl-0   :         3 (100.00%)
       deltas    :   0 ( 0.00%)
   revision size : 191
-      full      : 191 (100.00%)
-      inter     :   0 ( 0.00%)
+      snapshot  : 191 (100.00%)
+        lvl-0   :       191 (100.00%)
       deltas    :   0 ( 0.00%)
   
   chunks        :   3
@@ -46,6 +46,7 @@
   
   uncompressed data size (min/max/avg) : 57 / 66 / 62
   full revision size (min/max/avg)     : 58 / 67 / 63
+  inter-snapshot size (min/max/avg)    : 0 / 0 / 0
   delta size (min/max/avg)             : 0 / 0 / 0
   $ hg debugrevlog -m
   format : 1
@@ -58,12 +59,12 @@
       empty     :  1 (33.33%)
                      text  :  1 (100.00%)
                      delta :  0 ( 0.00%)
-      full      :  2 (66.67%)
-      inter     :  0 ( 0.00%)
+      snapshot  :  2 (66.67%)
+        lvl-0   :        2 (66.67%)
       deltas    :  0 ( 0.00%)
   revision size : 88
-      full      : 88 (100.00%)
-      inter     :  0 ( 0.00%)
+      snapshot  : 88 (100.00%)
+        lvl-0   :       88 (100.00%)
       deltas    :  0 ( 0.00%)
   
   chunks        :  3
@@ -80,6 +81,7 @@
   
   uncompressed data size (min/max/avg) : 0 / 43 / 28
   full revision size (min/max/avg)     : 44 / 44 / 44
+  inter-snapshot size (min/max/avg)    : 0 / 0 / 0
   delta size (min/max/avg)             : 0 / 0 / 0
   $ hg debugrevlog a
   format : 1
@@ -92,12 +94,12 @@
       empty     : 0 ( 0.00%)
                      text  : 0 (100.00%)
                      delta : 0 (100.00%)
-      full      : 1 (100.00%)
-      inter     : 0 ( 0.00%)
+      snapshot  : 1 (100.00%)
+        lvl-0   :       1 (100.00%)
       deltas    : 0 ( 0.00%)
   revision size : 3
-      full      : 3 (100.00%)
-      inter     : 0 ( 0.00%)
+      snapshot  : 3 (100.00%)
+        lvl-0   :       3 (100.00%)
       deltas    : 0 ( 0.00%)
   
   chunks        : 1
@@ -112,6 +114,7 @@
   
   uncompressed data size (min/max/avg) : 2 / 2 / 2
   full revision size (min/max/avg)     : 3 / 3 / 3
+  inter-snapshot size (min/max/avg)    : 0 / 0 / 0
   delta size (min/max/avg)             : 0 / 0 / 0
 #endif