changeset 35678:43154a76f392

debugdeltachain: display how many chunks would be read in sparse-read mode
author Paul Morelle <paul.morelle@octobus.net>
date Mon, 16 Oct 2017 14:32:06 +0200
parents cf2e2a7399bc
children 5a2d505a9174
files mercurial/debugcommands.py tests/test-debugcommands.t
diffstat 2 files changed, 46 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Wed Jan 17 21:36:18 2018 +0000
+++ b/mercurial/debugcommands.py	Mon Oct 16 14:32:06 2017 +0200
@@ -600,6 +600,7 @@
                        (sum of the sizes of all the blocks)
     :``largestblock``: size of the largest block of data read from the disk
     :``readdensity``:  density of useful bytes in the data read from the disk
+    :``srchunks``:  in how many data hunks the whole revision would be read
 
     The sparse read can be enabled with experimental.sparse-read = True
     """
@@ -645,7 +646,7 @@
              'size    rawsize  chainsize     ratio   lindist extradist '
              'extraratio')
     if withsparseread:
-        fm.plain('   readsize largestblk rddensity')
+        fm.plain('   readsize largestblk rddensity srchunks')
     fm.plain('\n')
 
     chainbases = {}
@@ -693,11 +694,17 @@
 
             readdensity = float(chainsize) / float(readsize)
 
-            fm.write('readsize largestblock readdensity',
-                     ' %10d %10d %9.5f',
-                     readsize, largestblock, readdensity,
+            if util.safehasattr(revlog, '_slicechunk'):
+                revchunks = tuple(revlog._slicechunk(r, chain))
+            else:
+                revchunks = (chain,)
+            srchunks = len(revchunks)
+
+            fm.write('readsize largestblock readdensity srchunks',
+                     ' %10d %10d %9.5f %8d',
+                     readsize, largestblock, readdensity, srchunks,
                      readsize=readsize, largestblock=largestblock,
-                     readdensity=readdensity)
+                     readdensity=readdensity, srchunks=srchunks)
 
         fm.plain('\n')
 
--- a/tests/test-debugcommands.t	Wed Jan 17 21:36:18 2018 +0000
+++ b/tests/test-debugcommands.t	Mon Oct 16 14:32:06 2017 +0200
@@ -86,8 +86,8 @@
   > sparse-read = True
   > EOF
   $ hg debugdeltachain -m
-      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio   readsize largestblk rddensity
-        0       1        1       -1    base         44         43         44   1.02326        44         0    0.00000         44         44   1.00000
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio   readsize largestblk rddensity srchunks
+        0       1        1       -1    base         44         43         44   1.02326        44         0    0.00000         44         44   1.00000        1
 
   $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen} {readsize} {largestblock} {readdensity}\n'
   0 1 1 44 44 1.0
@@ -109,10 +109,42 @@
     "readdensity": 1.0,
     "readsize": 44,
     "rev": 0,
+    "srchunks": 1,
     "uncompsize": 43
    }
   ]
 
+  $ printf "This test checks things.\n" >> a
+  $ hg ci -m a
+  $ hg branch other
+  marked working directory as branch other
+  (branches are permanent and global, did you want a bookmark?)
+  $ for i in `$TESTDIR/seq.py 5`; do
+  >   printf "shorter ${i}" >> a
+  >   hg ci -m "a other:$i"
+  >   hg up -q default
+  >   printf "for the branch default we want longer chains: ${i}" >> a
+  >   hg ci -m "a default:$i"
+  >   hg up -q other
+  > done
+  $ hg debugdeltachain a -T '{rev} {srchunks}\n' \
+  >    --config experimental.sparse-read.density-threshold=0.50 \
+  >    --config experimental.sparse-read.min-gap-size=0
+  0 1
+  1 1
+  2 1
+  3 1
+  4 1
+  5 1
+  6 1
+  7 1
+  8 1
+  9 1
+  10 2
+  11 1
+  $ hg --config extensions.strip= strip --no-backup -r 1
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
 Test max chain len
   $ cat >> $HGRCPATH << EOF
   > [format]