tests: use debugdeltachain where appropriate
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 02 Apr 2018 16:24:57 -0700
changeset 37281 806b07d7c7d6
parent 37280 435481393198
child 37282 009d0283de5f
tests: use debugdeltachain where appropriate Some tests are verifying delta chain type things. This metadata has more to do with a revlog implementation details than index data, which is theoretically generic. This commit ports some tests to `hg debugdeltachain`, as it is the more appropriate debug command for looking at delta metadata. Differential Revision: https://phab.mercurial-scm.org/D3026
tests/test-generaldelta.t
tests/test-parseindex.t
tests/test-upgrade-repo.t
--- a/tests/test-generaldelta.t	Mon Apr 02 15:55:50 2018 -0700
+++ b/tests/test-generaldelta.t	Mon Apr 02 16:24:57 2018 -0700
@@ -67,9 +67,9 @@
   $ hg init client --config format.generaldelta=false --config format.usegeneraldelta=false
   $ cd client
   $ hg pull -q ../server -r 4
-  $ hg debugindex x
-     rev    offset  length   base linkrev nodeid       p1           p2
-       0         0       3      0       1 1406e7411862 000000000000 000000000000
+  $ hg debugdeltachain x
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base          3          2          3   1.50000         3         0    0.00000
 
   $ cd ..
 
@@ -97,24 +97,24 @@
   new changesets 0ea3fcf9d01d:bba78d330d9c
   updating to branch default
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg -R repo debugindex -m
-     rev    offset  length   base linkrev nodeid       p1           p2
-       0         0     104      0       0 cef96823c800 000000000000 000000000000
-       1       104      57      0       1 58ab9a8d541d cef96823c800 000000000000
-       2       161      57      0       2 134fdc6fd680 cef96823c800 000000000000
-       3       218     104      3       3 723508934dad cef96823c800 000000000000
-  $ hg -R usegd debugindex -m
-     rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0     104     -1       0 cef96823c800 000000000000 000000000000
-       1       104      57      0       1 58ab9a8d541d cef96823c800 000000000000
-       2       161      57      1       2 134fdc6fd680 cef96823c800 000000000000
-       3       218      57      0       3 723508934dad cef96823c800 000000000000
-  $ hg -R full debugindex -m
-     rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0     104     -1       0 cef96823c800 000000000000 000000000000
-       1       104      57      0       1 58ab9a8d541d cef96823c800 000000000000
-       2       161      57      0       2 134fdc6fd680 cef96823c800 000000000000
-       3       218      57      0       3 723508934dad cef96823c800 000000000000
+  $ hg -R repo debugdeltachain -m
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base        104        135        104   0.77037       104         0    0.00000
+        1       1        2        0    prev         57        135        161   1.19259       161         0    0.00000
+        2       1        3        1    prev         57        135        218   1.61481       218         0    0.00000
+        3       2        1       -1    base        104        135        104   0.77037       104         0    0.00000
+  $ hg -R usegd debugdeltachain -m
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base        104        135        104   0.77037       104         0    0.00000
+        1       1        2        0      p1         57        135        161   1.19259       161         0    0.00000
+        2       1        3        1    prev         57        135        218   1.61481       218         0    0.00000
+        3       1        2        0      p1         57        135        161   1.19259       275       114    0.70807
+  $ hg -R full debugdeltachain -m
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base        104        135        104   0.77037       104         0    0.00000
+        1       1        2        0      p1         57        135        161   1.19259       161         0    0.00000
+        2       1        2        0      p1         57        135        161   1.19259       218        57    0.35404
+        3       1        2        0      p1         57        135        161   1.19259       275       114    0.70807
 
 Test format.aggressivemergedeltas
 
@@ -133,11 +133,11 @@
 - Verify non-aggressive merge uses p1 (commit 1) as delta parent
   $ hg merge -q 0
   $ hg commit -q -m merge
-  $ hg debugindex -m
-     rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0      59     -1       0 8dde941edb6e 000000000000 000000000000
-       1        59      61      0       1 315c023f341d 000000000000 000000000000
-       2       120      65      1       2 2ab389a983eb 315c023f341d 8dde941edb6e
+  $ hg debugdeltachain -m
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base         59        215         59   0.27442        59         0    0.00000
+        1       1        2        0    prev         61         86        120   1.39535       120         0    0.00000
+        2       1        3        1      p1         65        301        185   0.61462       185         0    0.00000
 
   $ hg strip -q -r . --config extensions.strip=
 
@@ -145,11 +145,11 @@
   $ hg up -q -C 1
   $ hg merge -q 0
   $ hg commit -q -m merge --config format.aggressivemergedeltas=True
-  $ hg debugindex -m
-     rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0      59     -1       0 8dde941edb6e 000000000000 000000000000
-       1        59      61      0       1 315c023f341d 000000000000 000000000000
-       2       120      62      0       2 2ab389a983eb 315c023f341d 8dde941edb6e
+  $ hg debugdeltachain -m
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base         59        215         59   0.27442        59         0    0.00000
+        1       1        2        0    prev         61         86        120   1.39535       120         0    0.00000
+        2       1        2        0      p2         62        301        121   0.40199       182        61    0.50413
 
 Test that strip bundle use bundle2
   $ hg --config extensions.strip= strip .
@@ -171,61 +171,61 @@
   $ cd source-repo
   $ hg debugbuilddag --new-file '.+5:brancha$.+11:branchb$.+30:branchc<brancha+2<branchb+2'
   $ cd ..
-  $ hg -R source-repo debugindex -m
-     rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0      46     -1       0 19deeef41503 000000000000 000000000000
-       1        46      57      0       1 fffc37b38c40 19deeef41503 000000000000
-       2       103      57      1       2 5822d75c83d9 fffc37b38c40 000000000000
-       3       160      57      2       3 19cf2273e601 5822d75c83d9 000000000000
-       4       217      57      3       4 d45ead487afe 19cf2273e601 000000000000
-       5       274      57      4       5 96e0c2ce55ed d45ead487afe 000000000000
-       6       331      46     -1       6 0c2ea5222c74 000000000000 000000000000
-       7       377      57      6       7 4ca08a89134d 0c2ea5222c74 000000000000
-       8       434      57      7       8 c973dbfd30ac 4ca08a89134d 000000000000
-       9       491      57      8       9 d81d878ff2cd c973dbfd30ac 000000000000
-      10       548      58      9      10 dbee7f0dd760 d81d878ff2cd 000000000000
-      11       606      58     10      11 474be9f1fd4e dbee7f0dd760 000000000000
-      12       664      58     11      12 594a27502c85 474be9f1fd4e 000000000000
-      13       722      58     12      13 a7d25307d6a9 594a27502c85 000000000000
-      14       780      58     13      14 3eb53082272e a7d25307d6a9 000000000000
-      15       838      58     14      15 d1e94c85caf6 3eb53082272e 000000000000
-      16       896      58     15      16 8933d9629788 d1e94c85caf6 000000000000
-      17       954      58     16      17 a33416e52d91 8933d9629788 000000000000
-      18      1012      47     -1      18 4ccbf31021ed 000000000000 000000000000
-      19      1059      58     18      19 dcad7a25656c 4ccbf31021ed 000000000000
-      20      1117      58     19      20 617c4f8be75f dcad7a25656c 000000000000
-      21      1175      58     20      21 975b9c1d75bb 617c4f8be75f 000000000000
-      22      1233      58     21      22 74f09cd33b70 975b9c1d75bb 000000000000
-      23      1291      58     22      23 54e79bfa7ef1 74f09cd33b70 000000000000
-      24      1349      58     23      24 c556e7ff90af 54e79bfa7ef1 000000000000
-      25      1407      58     24      25 42daedfe9c6b c556e7ff90af 000000000000
-      26      1465      58     25      26 f302566947c7 42daedfe9c6b 000000000000
-      27      1523      58     26      27 2346959851cb f302566947c7 000000000000
-      28      1581      58     27      28 ca8d867106b4 2346959851cb 000000000000
-      29      1639      58     28      29 fd9152decab2 ca8d867106b4 000000000000
-      30      1697      58     29      30 3fe34080a79b fd9152decab2 000000000000
-      31      1755      58     30      31 bce61a95078e 3fe34080a79b 000000000000
-      32      1813      58     31      32 1dd9ba54ba15 bce61a95078e 000000000000
-      33      1871      58     32      33 3cd9b90a9972 1dd9ba54ba15 000000000000
-      34      1929      58     33      34 5db8c9754ef5 3cd9b90a9972 000000000000
-      35      1987      58     34      35 ee4a240cc16c 5db8c9754ef5 000000000000
-      36      2045      58     35      36 9e1d38725343 ee4a240cc16c 000000000000
-      37      2103      58     36      37 3463f73086a8 9e1d38725343 000000000000
-      38      2161      58     37      38 88af72fab449 3463f73086a8 000000000000
-      39      2219      58     38      39 472f5ce73785 88af72fab449 000000000000
-      40      2277      58     39      40 c91b8351e5b8 472f5ce73785 000000000000
-      41      2335      58     40      41 9c8289c5c5c0 c91b8351e5b8 000000000000
-      42      2393      58     41      42 a13fd4a09d76 9c8289c5c5c0 000000000000
-      43      2451      58     42      43 2ec2c81cafe0 a13fd4a09d76 000000000000
-      44      2509      58     43      44 f27fdd174392 2ec2c81cafe0 000000000000
-      45      2567      58     44      45 a539ec59fe41 f27fdd174392 000000000000
-      46      2625      58     45      46 5e98b9ecb738 a539ec59fe41 000000000000
-      47      2683      58     46      47 31e6b47899d0 5e98b9ecb738 000000000000
-      48      2741      58     47      48 2cf25d6636bd 31e6b47899d0 000000000000
-      49      2799     197     -1      49 9fff62ea0624 96e0c2ce55ed 000000000000
-      50      2996      58     49      50 467f8e30a066 9fff62ea0624 000000000000
-      51      3054     356     50      51 346db97283df a33416e52d91 000000000000
-      52      3410      58     51      52 4e003fd4d5cd 346db97283df 000000000000
+  $ hg -R source-repo debugdeltachain -m
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base         46         45         46   1.02222        46         0    0.00000
+        1       1        2        0      p1         57         90        103   1.14444       103         0    0.00000
+        2       1        3        1      p1         57        135        160   1.18519       160         0    0.00000
+        3       1        4        2      p1         57        180        217   1.20556       217         0    0.00000
+        4       1        5        3      p1         57        225        274   1.21778       274         0    0.00000
+        5       1        6        4      p1         57        270        331   1.22593       331         0    0.00000
+        6       2        1       -1    base         46         45         46   1.02222        46         0    0.00000
+        7       2        2        6      p1         57         90        103   1.14444       103         0    0.00000
+        8       2        3        7      p1         57        135        160   1.18519       160         0    0.00000
+        9       2        4        8      p1         57        180        217   1.20556       217         0    0.00000
+       10       2        5        9      p1         58        226        275   1.21681       275         0    0.00000
+       11       2        6       10      p1         58        272        333   1.22426       333         0    0.00000
+       12       2        7       11      p1         58        318        391   1.22956       391         0    0.00000
+       13       2        8       12      p1         58        364        449   1.23352       449         0    0.00000
+       14       2        9       13      p1         58        410        507   1.23659       507         0    0.00000
+       15       2       10       14      p1         58        456        565   1.23904       565         0    0.00000
+       16       2       11       15      p1         58        502        623   1.24104       623         0    0.00000
+       17       2       12       16      p1         58        548        681   1.24270       681         0    0.00000
+       18       3        1       -1    base         47         46         47   1.02174        47         0    0.00000
+       19       3        2       18      p1         58         92        105   1.14130       105         0    0.00000
+       20       3        3       19      p1         58        138        163   1.18116       163         0    0.00000
+       21       3        4       20      p1         58        184        221   1.20109       221         0    0.00000
+       22       3        5       21      p1         58        230        279   1.21304       279         0    0.00000
+       23       3        6       22      p1         58        276        337   1.22101       337         0    0.00000
+       24       3        7       23      p1         58        322        395   1.22671       395         0    0.00000
+       25       3        8       24      p1         58        368        453   1.23098       453         0    0.00000
+       26       3        9       25      p1         58        414        511   1.23430       511         0    0.00000
+       27       3       10       26      p1         58        460        569   1.23696       569         0    0.00000
+       28       3       11       27      p1         58        506        627   1.23913       627         0    0.00000
+       29       3       12       28      p1         58        552        685   1.24094       685         0    0.00000
+       30       3       13       29      p1         58        598        743   1.24247       743         0    0.00000
+       31       3       14       30      p1         58        644        801   1.24379       801         0    0.00000
+       32       3       15       31      p1         58        690        859   1.24493       859         0    0.00000
+       33       3       16       32      p1         58        736        917   1.24592       917         0    0.00000
+       34       3       17       33      p1         58        782        975   1.24680       975         0    0.00000
+       35       3       18       34      p1         58        828       1033   1.24758      1033         0    0.00000
+       36       3       19       35      p1         58        874       1091   1.24828      1091         0    0.00000
+       37       3       20       36      p1         58        920       1149   1.24891      1149         0    0.00000
+       38       3       21       37      p1         58        966       1207   1.24948      1207         0    0.00000
+       39       3       22       38      p1         58       1012       1265   1.25000      1265         0    0.00000
+       40       3       23       39      p1         58       1058       1323   1.25047      1323         0    0.00000
+       41       3       24       40      p1         58       1104       1381   1.25091      1381         0    0.00000
+       42       3       25       41      p1         58       1150       1439   1.25130      1439         0    0.00000
+       43       3       26       42      p1         58       1196       1497   1.25167      1497         0    0.00000
+       44       3       27       43      p1         58       1242       1555   1.25201      1555         0    0.00000
+       45       3       28       44      p1         58       1288       1613   1.25233      1613         0    0.00000
+       46       3       29       45      p1         58       1334       1671   1.25262      1671         0    0.00000
+       47       3       30       46      p1         58       1380       1729   1.25290      1729         0    0.00000
+       48       3       31       47      p1         58       1426       1787   1.25316      1787         0    0.00000
+       49       4        1       -1    base        197        316        197   0.62342       197         0    0.00000
+       50       4        2       49      p1         58        362        255   0.70442       255         0    0.00000
+       51       4        3       50    prev        356        594        611   1.02862       611         0    0.00000
+       52       4        4       51      p1         58        640        669   1.04531       669         0    0.00000
   $ hg clone --pull source-repo --config experimental.maxdeltachainspan=2800 relax-chain --config format.generaldelta=yes
   requesting all changes
   adding changesets
@@ -235,61 +235,61 @@
   new changesets 61246295ee1e:99cae3713489
   updating to branch default
   14 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg -R relax-chain debugindex -m
-     rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0      46     -1       0 19deeef41503 000000000000 000000000000
-       1        46      57      0       1 fffc37b38c40 19deeef41503 000000000000
-       2       103      57      1       2 5822d75c83d9 fffc37b38c40 000000000000
-       3       160      57      2       3 19cf2273e601 5822d75c83d9 000000000000
-       4       217      57      3       4 d45ead487afe 19cf2273e601 000000000000
-       5       274      57      4       5 96e0c2ce55ed d45ead487afe 000000000000
-       6       331      46     -1       6 0c2ea5222c74 000000000000 000000000000
-       7       377      57      6       7 4ca08a89134d 0c2ea5222c74 000000000000
-       8       434      57      7       8 c973dbfd30ac 4ca08a89134d 000000000000
-       9       491      57      8       9 d81d878ff2cd c973dbfd30ac 000000000000
-      10       548      58      9      10 dbee7f0dd760 d81d878ff2cd 000000000000
-      11       606      58     10      11 474be9f1fd4e dbee7f0dd760 000000000000
-      12       664      58     11      12 594a27502c85 474be9f1fd4e 000000000000
-      13       722      58     12      13 a7d25307d6a9 594a27502c85 000000000000
-      14       780      58     13      14 3eb53082272e a7d25307d6a9 000000000000
-      15       838      58     14      15 d1e94c85caf6 3eb53082272e 000000000000
-      16       896      58     15      16 8933d9629788 d1e94c85caf6 000000000000
-      17       954      58     16      17 a33416e52d91 8933d9629788 000000000000
-      18      1012      47     -1      18 4ccbf31021ed 000000000000 000000000000
-      19      1059      58     18      19 dcad7a25656c 4ccbf31021ed 000000000000
-      20      1117      58     19      20 617c4f8be75f dcad7a25656c 000000000000
-      21      1175      58     20      21 975b9c1d75bb 617c4f8be75f 000000000000
-      22      1233      58     21      22 74f09cd33b70 975b9c1d75bb 000000000000
-      23      1291      58     22      23 54e79bfa7ef1 74f09cd33b70 000000000000
-      24      1349      58     23      24 c556e7ff90af 54e79bfa7ef1 000000000000
-      25      1407      58     24      25 42daedfe9c6b c556e7ff90af 000000000000
-      26      1465      58     25      26 f302566947c7 42daedfe9c6b 000000000000
-      27      1523      58     26      27 2346959851cb f302566947c7 000000000000
-      28      1581      58     27      28 ca8d867106b4 2346959851cb 000000000000
-      29      1639      58     28      29 fd9152decab2 ca8d867106b4 000000000000
-      30      1697      58     29      30 3fe34080a79b fd9152decab2 000000000000
-      31      1755      58     30      31 bce61a95078e 3fe34080a79b 000000000000
-      32      1813      58     31      32 1dd9ba54ba15 bce61a95078e 000000000000
-      33      1871      58     32      33 3cd9b90a9972 1dd9ba54ba15 000000000000
-      34      1929      58     33      34 5db8c9754ef5 3cd9b90a9972 000000000000
-      35      1987      58     34      35 ee4a240cc16c 5db8c9754ef5 000000000000
-      36      2045      58     35      36 9e1d38725343 ee4a240cc16c 000000000000
-      37      2103      58     36      37 3463f73086a8 9e1d38725343 000000000000
-      38      2161      58     37      38 88af72fab449 3463f73086a8 000000000000
-      39      2219      58     38      39 472f5ce73785 88af72fab449 000000000000
-      40      2277      58     39      40 c91b8351e5b8 472f5ce73785 000000000000
-      41      2335      58     40      41 9c8289c5c5c0 c91b8351e5b8 000000000000
-      42      2393      58     41      42 a13fd4a09d76 9c8289c5c5c0 000000000000
-      43      2451      58     42      43 2ec2c81cafe0 a13fd4a09d76 000000000000
-      44      2509      58     43      44 f27fdd174392 2ec2c81cafe0 000000000000
-      45      2567      58     44      45 a539ec59fe41 f27fdd174392 000000000000
-      46      2625      58     45      46 5e98b9ecb738 a539ec59fe41 000000000000
-      47      2683      58     46      47 31e6b47899d0 5e98b9ecb738 000000000000
-      48      2741      58     47      48 2cf25d6636bd 31e6b47899d0 000000000000
-      49      2799     197     -1      49 9fff62ea0624 96e0c2ce55ed 000000000000
-      50      2996      58     49      50 467f8e30a066 9fff62ea0624 000000000000
-      51      3054      58     17      51 346db97283df a33416e52d91 000000000000
-      52      3112     369     -1      52 4e003fd4d5cd 346db97283df 000000000000
+  $ hg -R relax-chain debugdeltachain -m
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base         46         45         46   1.02222        46         0    0.00000
+        1       1        2        0      p1         57         90        103   1.14444       103         0    0.00000
+        2       1        3        1      p1         57        135        160   1.18519       160         0    0.00000
+        3       1        4        2      p1         57        180        217   1.20556       217         0    0.00000
+        4       1        5        3      p1         57        225        274   1.21778       274         0    0.00000
+        5       1        6        4      p1         57        270        331   1.22593       331         0    0.00000
+        6       2        1       -1    base         46         45         46   1.02222        46         0    0.00000
+        7       2        2        6      p1         57         90        103   1.14444       103         0    0.00000
+        8       2        3        7      p1         57        135        160   1.18519       160         0    0.00000
+        9       2        4        8      p1         57        180        217   1.20556       217         0    0.00000
+       10       2        5        9      p1         58        226        275   1.21681       275         0    0.00000
+       11       2        6       10      p1         58        272        333   1.22426       333         0    0.00000
+       12       2        7       11      p1         58        318        391   1.22956       391         0    0.00000
+       13       2        8       12      p1         58        364        449   1.23352       449         0    0.00000
+       14       2        9       13      p1         58        410        507   1.23659       507         0    0.00000
+       15       2       10       14      p1         58        456        565   1.23904       565         0    0.00000
+       16       2       11       15      p1         58        502        623   1.24104       623         0    0.00000
+       17       2       12       16      p1         58        548        681   1.24270       681         0    0.00000
+       18       3        1       -1    base         47         46         47   1.02174        47         0    0.00000
+       19       3        2       18      p1         58         92        105   1.14130       105         0    0.00000
+       20       3        3       19      p1         58        138        163   1.18116       163         0    0.00000
+       21       3        4       20      p1         58        184        221   1.20109       221         0    0.00000
+       22       3        5       21      p1         58        230        279   1.21304       279         0    0.00000
+       23       3        6       22      p1         58        276        337   1.22101       337         0    0.00000
+       24       3        7       23      p1         58        322        395   1.22671       395         0    0.00000
+       25       3        8       24      p1         58        368        453   1.23098       453         0    0.00000
+       26       3        9       25      p1         58        414        511   1.23430       511         0    0.00000
+       27       3       10       26      p1         58        460        569   1.23696       569         0    0.00000
+       28       3       11       27      p1         58        506        627   1.23913       627         0    0.00000
+       29       3       12       28      p1         58        552        685   1.24094       685         0    0.00000
+       30       3       13       29      p1         58        598        743   1.24247       743         0    0.00000
+       31       3       14       30      p1         58        644        801   1.24379       801         0    0.00000
+       32       3       15       31      p1         58        690        859   1.24493       859         0    0.00000
+       33       3       16       32      p1         58        736        917   1.24592       917         0    0.00000
+       34       3       17       33      p1         58        782        975   1.24680       975         0    0.00000
+       35       3       18       34      p1         58        828       1033   1.24758      1033         0    0.00000
+       36       3       19       35      p1         58        874       1091   1.24828      1091         0    0.00000
+       37       3       20       36      p1         58        920       1149   1.24891      1149         0    0.00000
+       38       3       21       37      p1         58        966       1207   1.24948      1207         0    0.00000
+       39       3       22       38      p1         58       1012       1265   1.25000      1265         0    0.00000
+       40       3       23       39      p1         58       1058       1323   1.25047      1323         0    0.00000
+       41       3       24       40      p1         58       1104       1381   1.25091      1381         0    0.00000
+       42       3       25       41      p1         58       1150       1439   1.25130      1439         0    0.00000
+       43       3       26       42      p1         58       1196       1497   1.25167      1497         0    0.00000
+       44       3       27       43      p1         58       1242       1555   1.25201      1555         0    0.00000
+       45       3       28       44      p1         58       1288       1613   1.25233      1613         0    0.00000
+       46       3       29       45      p1         58       1334       1671   1.25262      1671         0    0.00000
+       47       3       30       46      p1         58       1380       1729   1.25290      1729         0    0.00000
+       48       3       31       47      p1         58       1426       1787   1.25316      1787         0    0.00000
+       49       4        1       -1    base        197        316        197   0.62342       197         0    0.00000
+       50       4        2       49      p1         58        362        255   0.70442       255         0    0.00000
+       51       2       13       17      p1         58        594        739   1.24411      2781      2042    2.76319
+       52       5        1       -1    base        369        640        369   0.57656       369         0    0.00000
   $ hg clone --pull source-repo --config experimental.maxdeltachainspan=0 noconst-chain --config format.generaldelta=yes
   requesting all changes
   adding changesets
@@ -299,58 +299,58 @@
   new changesets 61246295ee1e:99cae3713489
   updating to branch default
   14 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg -R noconst-chain debugindex -m
-     rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0      46     -1       0 19deeef41503 000000000000 000000000000
-       1        46      57      0       1 fffc37b38c40 19deeef41503 000000000000
-       2       103      57      1       2 5822d75c83d9 fffc37b38c40 000000000000
-       3       160      57      2       3 19cf2273e601 5822d75c83d9 000000000000
-       4       217      57      3       4 d45ead487afe 19cf2273e601 000000000000
-       5       274      57      4       5 96e0c2ce55ed d45ead487afe 000000000000
-       6       331      46     -1       6 0c2ea5222c74 000000000000 000000000000
-       7       377      57      6       7 4ca08a89134d 0c2ea5222c74 000000000000
-       8       434      57      7       8 c973dbfd30ac 4ca08a89134d 000000000000
-       9       491      57      8       9 d81d878ff2cd c973dbfd30ac 000000000000
-      10       548      58      9      10 dbee7f0dd760 d81d878ff2cd 000000000000
-      11       606      58     10      11 474be9f1fd4e dbee7f0dd760 000000000000
-      12       664      58     11      12 594a27502c85 474be9f1fd4e 000000000000
-      13       722      58     12      13 a7d25307d6a9 594a27502c85 000000000000
-      14       780      58     13      14 3eb53082272e a7d25307d6a9 000000000000
-      15       838      58     14      15 d1e94c85caf6 3eb53082272e 000000000000
-      16       896      58     15      16 8933d9629788 d1e94c85caf6 000000000000
-      17       954      58     16      17 a33416e52d91 8933d9629788 000000000000
-      18      1012      47     -1      18 4ccbf31021ed 000000000000 000000000000
-      19      1059      58     18      19 dcad7a25656c 4ccbf31021ed 000000000000
-      20      1117      58     19      20 617c4f8be75f dcad7a25656c 000000000000
-      21      1175      58     20      21 975b9c1d75bb 617c4f8be75f 000000000000
-      22      1233      58     21      22 74f09cd33b70 975b9c1d75bb 000000000000
-      23      1291      58     22      23 54e79bfa7ef1 74f09cd33b70 000000000000
-      24      1349      58     23      24 c556e7ff90af 54e79bfa7ef1 000000000000
-      25      1407      58     24      25 42daedfe9c6b c556e7ff90af 000000000000
-      26      1465      58     25      26 f302566947c7 42daedfe9c6b 000000000000
-      27      1523      58     26      27 2346959851cb f302566947c7 000000000000
-      28      1581      58     27      28 ca8d867106b4 2346959851cb 000000000000
-      29      1639      58     28      29 fd9152decab2 ca8d867106b4 000000000000
-      30      1697      58     29      30 3fe34080a79b fd9152decab2 000000000000
-      31      1755      58     30      31 bce61a95078e 3fe34080a79b 000000000000
-      32      1813      58     31      32 1dd9ba54ba15 bce61a95078e 000000000000
-      33      1871      58     32      33 3cd9b90a9972 1dd9ba54ba15 000000000000
-      34      1929      58     33      34 5db8c9754ef5 3cd9b90a9972 000000000000
-      35      1987      58     34      35 ee4a240cc16c 5db8c9754ef5 000000000000
-      36      2045      58     35      36 9e1d38725343 ee4a240cc16c 000000000000
-      37      2103      58     36      37 3463f73086a8 9e1d38725343 000000000000
-      38      2161      58     37      38 88af72fab449 3463f73086a8 000000000000
-      39      2219      58     38      39 472f5ce73785 88af72fab449 000000000000
-      40      2277      58     39      40 c91b8351e5b8 472f5ce73785 000000000000
-      41      2335      58     40      41 9c8289c5c5c0 c91b8351e5b8 000000000000
-      42      2393      58     41      42 a13fd4a09d76 9c8289c5c5c0 000000000000
-      43      2451      58     42      43 2ec2c81cafe0 a13fd4a09d76 000000000000
-      44      2509      58     43      44 f27fdd174392 2ec2c81cafe0 000000000000
-      45      2567      58     44      45 a539ec59fe41 f27fdd174392 000000000000
-      46      2625      58     45      46 5e98b9ecb738 a539ec59fe41 000000000000
-      47      2683      58     46      47 31e6b47899d0 5e98b9ecb738 000000000000
-      48      2741      58     47      48 2cf25d6636bd 31e6b47899d0 000000000000
-      49      2799      58      5      49 9fff62ea0624 96e0c2ce55ed 000000000000
-      50      2857      58     49      50 467f8e30a066 9fff62ea0624 000000000000
-      51      2915      58     17      51 346db97283df a33416e52d91 000000000000
-      52      2973      58     51      52 4e003fd4d5cd 346db97283df 000000000000
+  $ hg -R noconst-chain debugdeltachain -m
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base         46         45         46   1.02222        46         0    0.00000
+        1       1        2        0      p1         57         90        103   1.14444       103         0    0.00000
+        2       1        3        1      p1         57        135        160   1.18519       160         0    0.00000
+        3       1        4        2      p1         57        180        217   1.20556       217         0    0.00000
+        4       1        5        3      p1         57        225        274   1.21778       274         0    0.00000
+        5       1        6        4      p1         57        270        331   1.22593       331         0    0.00000
+        6       2        1       -1    base         46         45         46   1.02222        46         0    0.00000
+        7       2        2        6      p1         57         90        103   1.14444       103         0    0.00000
+        8       2        3        7      p1         57        135        160   1.18519       160         0    0.00000
+        9       2        4        8      p1         57        180        217   1.20556       217         0    0.00000
+       10       2        5        9      p1         58        226        275   1.21681       275         0    0.00000
+       11       2        6       10      p1         58        272        333   1.22426       333         0    0.00000
+       12       2        7       11      p1         58        318        391   1.22956       391         0    0.00000
+       13       2        8       12      p1         58        364        449   1.23352       449         0    0.00000
+       14       2        9       13      p1         58        410        507   1.23659       507         0    0.00000
+       15       2       10       14      p1         58        456        565   1.23904       565         0    0.00000
+       16       2       11       15      p1         58        502        623   1.24104       623         0    0.00000
+       17       2       12       16      p1         58        548        681   1.24270       681         0    0.00000
+       18       3        1       -1    base         47         46         47   1.02174        47         0    0.00000
+       19       3        2       18      p1         58         92        105   1.14130       105         0    0.00000
+       20       3        3       19      p1         58        138        163   1.18116       163         0    0.00000
+       21       3        4       20      p1         58        184        221   1.20109       221         0    0.00000
+       22       3        5       21      p1         58        230        279   1.21304       279         0    0.00000
+       23       3        6       22      p1         58        276        337   1.22101       337         0    0.00000
+       24       3        7       23      p1         58        322        395   1.22671       395         0    0.00000
+       25       3        8       24      p1         58        368        453   1.23098       453         0    0.00000
+       26       3        9       25      p1         58        414        511   1.23430       511         0    0.00000
+       27       3       10       26      p1         58        460        569   1.23696       569         0    0.00000
+       28       3       11       27      p1         58        506        627   1.23913       627         0    0.00000
+       29       3       12       28      p1         58        552        685   1.24094       685         0    0.00000
+       30       3       13       29      p1         58        598        743   1.24247       743         0    0.00000
+       31       3       14       30      p1         58        644        801   1.24379       801         0    0.00000
+       32       3       15       31      p1         58        690        859   1.24493       859         0    0.00000
+       33       3       16       32      p1         58        736        917   1.24592       917         0    0.00000
+       34       3       17       33      p1         58        782        975   1.24680       975         0    0.00000
+       35       3       18       34      p1         58        828       1033   1.24758      1033         0    0.00000
+       36       3       19       35      p1         58        874       1091   1.24828      1091         0    0.00000
+       37       3       20       36      p1         58        920       1149   1.24891      1149         0    0.00000
+       38       3       21       37      p1         58        966       1207   1.24948      1207         0    0.00000
+       39       3       22       38      p1         58       1012       1265   1.25000      1265         0    0.00000
+       40       3       23       39      p1         58       1058       1323   1.25047      1323         0    0.00000
+       41       3       24       40      p1         58       1104       1381   1.25091      1381         0    0.00000
+       42       3       25       41      p1         58       1150       1439   1.25130      1439         0    0.00000
+       43       3       26       42      p1         58       1196       1497   1.25167      1497         0    0.00000
+       44       3       27       43      p1         58       1242       1555   1.25201      1555         0    0.00000
+       45       3       28       44      p1         58       1288       1613   1.25233      1613         0    0.00000
+       46       3       29       45      p1         58       1334       1671   1.25262      1671         0    0.00000
+       47       3       30       46      p1         58       1380       1729   1.25290      1729         0    0.00000
+       48       3       31       47      p1         58       1426       1787   1.25316      1787         0    0.00000
+       49       1        7        5      p1         58        316        389   1.23101      2857      2468    6.34447
+       50       1        8       49      p1         58        362        447   1.23481      2915      2468    5.52125
+       51       2       13       17      p1         58        594        739   1.24411      2642      1903    2.57510
+       52       2       14       51      p1         58        640        797   1.24531      2700      1903    2.38770
--- a/tests/test-parseindex.t	Mon Apr 02 15:55:50 2018 -0700
+++ b/tests/test-parseindex.t	Mon Apr 02 16:24:57 2018 -0700
@@ -147,11 +147,22 @@
      rev flag   offset   length     size   base   link     p1     p2       nodeid
        0 0000        0       63       62      0      0      2     -1 7c31755bf9b5
        1 0000       63       66       65      1      1      0      2 26333235a41c
+
+  $ hg -R limit debugdeltachain -c
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base         63         62         63   1.01613        63         0    0.00000
+        1       2        1       -1    base         66         65         66   1.01538        66         0    0.00000
+
   $ hg -R segv debugindex -f1 -c
      rev flag   offset   length     size   base   link     p1     p2       nodeid
        0 0000        0       63       62      0      0  65536     -1 7c31755bf9b5
        1 0000       63       66       65      1      1      0  65536 26333235a41c
 
+  $ hg -R segv debugdeltachain -c
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base         63         62         63   1.01613        63         0    0.00000
+        1       2        1       -1    base         66         65         66   1.01538        66         0    0.00000
+
   $ cat <<EOF > test.py
   > import sys
   > from mercurial import changelog, vfs
--- a/tests/test-upgrade-repo.t	Mon Apr 02 15:55:50 2018 -0700
+++ b/tests/test-upgrade-repo.t	Mon Apr 02 16:24:57 2018 -0700
@@ -645,11 +645,11 @@
   > EOF
   $ hg config format
   format.maxchainlen=9001
-  $ hg debugindex file
-     rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0      77     -1       0 bcc1d3df78b2 000000000000 000000000000
-       1        77      21      0       1 af3e29f7a72e bcc1d3df78b2 000000000000
-       2        98      84     -1       2 8daf79c5522b af3e29f7a72e 000000000000
+  $ hg debugdeltachain file
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base         77        182         77   0.42308        77         0    0.00000
+        1       1        2        0      p1         21        191         98   0.51309        98         0    0.00000
+        2       2        1       -1    base         84        200         84   0.42000        84         0    0.00000
 
   $ hg debugupgraderepo --run --optimize redeltaall
   upgrade will perform the following actions:
@@ -684,11 +684,11 @@
   removing temporary repository $TESTTMP/localconfig/.hg/upgrade.* (glob)
   copy of old repository backed up at $TESTTMP/localconfig/.hg/upgradebackup.* (glob)
   the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
-  $ hg debugindex file
-     rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0      77     -1       0 bcc1d3df78b2 000000000000 000000000000
-       1        77      21      0       1 af3e29f7a72e bcc1d3df78b2 000000000000
-       2        98      21      1       2 8daf79c5522b af3e29f7a72e 000000000000
+  $ hg debugdeltachain file
+      rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
+        0       1        1       -1    base         77        182         77   0.42308        77         0    0.00000
+        1       1        2        0      p1         21        191         98   0.51309        98         0    0.00000
+        2       1        3        1      p1         21        200        119   0.59500       119         0    0.00000
   $ cd ..
 
   $ cat << EOF >> $HGRCPATH