[PATCH] debugdeltachain: display how many chunks would be read in sparse-read mode

Paul Morelle paul.morelle at octobus.net
Wed Jan 17 13:27:46 UTC 2018


# HG changeset patch
# User Paul Morelle <paul.morelle at octobus.net>
# Date 1508157126 -7200
#      Mon Oct 16 14:32:06 2017 +0200
# Node ID 3f03791f818c1148b969e0635855ae751a1909c5
# Parent  821d8a5ab4ff890a7732c2e4cdcc7f32191e5942
# EXP-Topic debug-sparse-read
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 3f03791f818c
debugdeltachain: display how many chunks would be read in sparse-read mode

diff -r 821d8a5ab4ff -r 3f03791f818c mercurial/debugcommands.py
--- a/mercurial/debugcommands.py	Tue Jan 16 22:14:33 2018 +0900
+++ 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')
 
diff -r 821d8a5ab4ff -r 3f03791f818c tests/test-debugcommands.t
--- a/tests/test-debugcommands.t	Tue Jan 16 22:14:33 2018 +0900
+++ 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]
@@ -312,38 +344,3 @@
   from h hidden in g at:
    debugstacktrace.py:6 in f
    debugstacktrace.py:9 in g
-
-Test debugcapabilities command:
-
-  $ hg debugcapabilities ./debugrevlog/
-  Main capabilities:
-    branchmap
-    $USUAL_BUNDLE2_CAPS$
-    getbundle
-    known
-    lookup
-    pushkey
-    unbundle
-  Bundle2 capabilities:
-    HG20
-    bookmarks
-    changegroup
-      01
-      02
-    digests
-      md5
-      sha1
-      sha512
-    error
-      abort
-      unsupportedcontent
-      pushraced
-      pushkey
-    hgtagsfnodes
-    listkeys
-    phases
-      heads
-    pushkey
-    remote-changegroup
-      http
-      https


More information about the Mercurial-devel mailing list