Patchwork [04,of,10] debugrevlog: include information about intermediate snapshots

login
register
mail settings
Submitter Boris Feld
Date Aug. 16, 2018, 1:43 p.m.
Message ID <23af56696ff32b017257.1534426991@FB-lair>
Download mbox | patch
Permalink /patch/33780/
State Accepted
Headers show

Comments

Boris Feld - Aug. 16, 2018, 1:43 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1532681563 -7200
#      Fri Jul 27 10:52:43 2018 +0200
# Node ID 23af56696ff32b0172570e4430775a7793d9d8f9
# Parent  44f26261d97dddc70ddcd3a08b0e7597c4179b39
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 23af56696ff3
debugrevlog: include information about intermediate snapshots

As we are about to create intermediate snapshots, we need to have a way to
debug them. We start by adding very simple debug output and more detailed
output will comes in next changesets.

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2095,6 +2095,8 @@  def debugrevlog(ui, repo, file_=None, **
     numemptydelta = 0
     # full file content
     numfull = 0
+    # intermediate snapshot against a prior snapshot
+    numsemi = 0
     # delta against previous revision
     numprev = 0
     # delta against first or second parent (not prev)
@@ -2115,6 +2117,7 @@  def debugrevlog(ui, repo, file_=None, **
     # data about each revision
     datasize = [None, 0, 0]
     fullsize = [None, 0, 0]
+    semisize = [None, 0, 0]
     deltasize = [None, 0, 0]
     chunktypecounts = {}
     chunktypesizes = {}
@@ -2154,6 +2157,9 @@  def debugrevlog(ui, repo, file_=None, **
             if size == 0:
                 numempty += 1
                 numemptydelta += 1
+            elif r.issnapshot(rev):
+                addsize(size, semisize)
+                numsemi += 1
             else:
                 addsize(size, deltasize)
                 if delta == rev - 1:
@@ -2187,20 +2193,23 @@  def debugrevlog(ui, repo, file_=None, **
         chunktypesizes[chunktype] += size
 
     # Adjust size min value for empty cases
-    for size in (datasize, fullsize, deltasize):
+    for size in (datasize, fullsize, semisize, deltasize):
         if size[0] is None:
             size[0] = 0
 
-    numdeltas = numrevs - numfull - numempty
+    numdeltas = numrevs - numfull - numempty - numsemi
     numoprev = numprev - nump1prev - nump2prev
     totalrawsize = datasize[2]
     datasize[2] /= numrevs
     fulltotal = fullsize[2]
     fullsize[2] /= numfull
+    semitotal = semisize[2]
+    if 0 < numsemi:
+        semisize[2] /= numsemi
     deltatotal = deltasize[2]
     if numdeltas > 0:
         deltasize[2] /= numdeltas
-    totalsize = fulltotal + deltatotal
+    totalsize = fulltotal + semitotal + deltatotal
     avgchainlen = sum(chainlengths) / numrevs
     maxchainlen = max(chainlengths)
     maxchainspan = max(chainspans)
@@ -2238,9 +2247,11 @@  def debugrevlog(ui, repo, file_=None, **
     ui.write(('                   delta : ')
              + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta))
     ui.write(('    full      : ') + fmt % pcfmt(numfull, numrevs))
+    ui.write(('    inter     : ') + fmt % pcfmt(numsemi, 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(('    deltas    : ') + fmt % pcfmt(deltatotal, totalsize))
 
     def fmtchunktype(chunktype):
diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t
--- a/tests/test-debugcommands.t
+++ b/tests/test-debugcommands.t
@@ -27,9 +27,11 @@ 
                      text  :   0 (100.00%)
                      delta :   0 (100.00%)
       full      :   3 (100.00%)
+      inter     :   0 ( 0.00%)
       deltas    :   0 ( 0.00%)
   revision size : 191
       full      : 191 (100.00%)
+      inter     :   0 ( 0.00%)
       deltas    :   0 ( 0.00%)
   
   chunks        :   3
@@ -57,9 +59,11 @@ 
                      text  :  1 (100.00%)
                      delta :  0 ( 0.00%)
       full      :  2 (66.67%)
+      inter     :  0 ( 0.00%)
       deltas    :  0 ( 0.00%)
   revision size : 88
       full      : 88 (100.00%)
+      inter     :  0 ( 0.00%)
       deltas    :  0 ( 0.00%)
   
   chunks        :  3
@@ -89,9 +93,11 @@ 
                      text  : 0 (100.00%)
                      delta : 0 (100.00%)
       full      : 1 (100.00%)
+      inter     : 0 ( 0.00%)
       deltas    : 0 ( 0.00%)
   revision size : 3
       full      : 3 (100.00%)
+      inter     : 0 ( 0.00%)
       deltas    : 0 ( 0.00%)
   
   chunks        : 1