debugindex: add a `p2-rev` column
authorPierre-Yves DAVID <pierre-yves.david@octobus.net>
Wed, 01 Jun 2022 01:32:54 +0200
changeset 49256 d910ca4e995b
parent 49255 251650844331
child 49257 b0238fc496af
debugindex: add a `p2-rev` column This will be useful in case of corrupted index.
mercurial/revlogutils/debug.py
tests/test-debugcommands.t
tests/test-sidedata.t
--- a/mercurial/revlogutils/debug.py	Wed Jun 01 01:32:45 2022 +0200
+++ b/mercurial/revlogutils/debug.py	Wed Jun 01 01:32:54 2022 +0200
@@ -92,6 +92,11 @@
     return hexfn(p_entry[constants.ENTRY_NODE_ID])
 
 
+@debug_column(b"p2-rev", size=6, verbose=True)
+def _p2_rev(index, rev, entry, hexfn):
+    return b"%d" % entry[constants.ENTRY_PARENT_2]
+
+
 @debug_column(b"p2-nodeid", size=NODE_SIZE)
 def _p2_node(index, rev, entry, hexfn):
     parent = entry[constants.ENTRY_PARENT_2]
--- a/tests/test-debugcommands.t	Wed Jun 01 01:32:45 2022 +0200
+++ b/tests/test-debugcommands.t	Wed Jun 01 01:32:54 2022 +0200
@@ -153,26 +153,26 @@
        1       1 8cccb4b5fec2 07f494440405 000000000000
        2       2 b1e228c512c5 8cccb4b5fec2 000000000000
   $ hg debugindex -c --debug
-     rev linkrev                                   nodeid p1-rev                                p1-nodeid                                p2-nodeid
-       0       0 07f4944404050f47db2e5c5071e0e84e7a27bba9     -1 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
-       1       1 8cccb4b5fec20cafeb99dd01c26d4dee8ea4388a      0 07f4944404050f47db2e5c5071e0e84e7a27bba9 0000000000000000000000000000000000000000
-       2       2 b1e228c512c5d7066d70562ed839c3323a62d6d2      1 8cccb4b5fec20cafeb99dd01c26d4dee8ea4388a 0000000000000000000000000000000000000000
+     rev linkrev                                   nodeid p1-rev                                p1-nodeid p2-rev                                p2-nodeid
+       0       0 07f4944404050f47db2e5c5071e0e84e7a27bba9     -1 0000000000000000000000000000000000000000     -1 0000000000000000000000000000000000000000
+       1       1 8cccb4b5fec20cafeb99dd01c26d4dee8ea4388a      0 07f4944404050f47db2e5c5071e0e84e7a27bba9     -1 0000000000000000000000000000000000000000
+       2       2 b1e228c512c5d7066d70562ed839c3323a62d6d2      1 8cccb4b5fec20cafeb99dd01c26d4dee8ea4388a     -1 0000000000000000000000000000000000000000
   $ hg debugindex -m
      rev linkrev       nodeid    p1-nodeid    p2-nodeid
        0       0 a0c8bcbbb45c 000000000000 000000000000
        1       1 57faf8a737ae a0c8bcbbb45c 000000000000
        2       2 a35b10320954 57faf8a737ae 000000000000
   $ hg debugindex -m --debug
-     rev linkrev                                   nodeid p1-rev                                p1-nodeid                                p2-nodeid
-       0       0 a0c8bcbbb45c63b90b70ad007bf38961f64f2af0     -1 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
-       1       1 57faf8a737ae7faf490582941a82319ba6529dca      0 a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 0000000000000000000000000000000000000000
-       2       2 a35b103209548032201c16c7688cb2657f037a38      1 57faf8a737ae7faf490582941a82319ba6529dca 0000000000000000000000000000000000000000
+     rev linkrev                                   nodeid p1-rev                                p1-nodeid p2-rev                                p2-nodeid
+       0       0 a0c8bcbbb45c63b90b70ad007bf38961f64f2af0     -1 0000000000000000000000000000000000000000     -1 0000000000000000000000000000000000000000
+       1       1 57faf8a737ae7faf490582941a82319ba6529dca      0 a0c8bcbbb45c63b90b70ad007bf38961f64f2af0     -1 0000000000000000000000000000000000000000
+       2       2 a35b103209548032201c16c7688cb2657f037a38      1 57faf8a737ae7faf490582941a82319ba6529dca     -1 0000000000000000000000000000000000000000
   $ hg debugindex a
      rev linkrev       nodeid    p1-nodeid    p2-nodeid
        0       0 b789fdd96dc2 000000000000 000000000000
   $ hg debugindex --debug a
-     rev linkrev                                   nodeid p1-rev                                p1-nodeid                                p2-nodeid
-       0       0 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3     -1 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
+     rev linkrev                                   nodeid p1-rev                                p1-nodeid p2-rev                                p2-nodeid
+       0       0 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3     -1 0000000000000000000000000000000000000000     -1 0000000000000000000000000000000000000000
 
 debugdelta chain basic output
 
--- a/tests/test-sidedata.t	Wed Jun 01 01:32:45 2022 +0200
+++ b/tests/test-sidedata.t	Wed Jun 01 01:32:54 2022 +0200
@@ -41,16 +41,16 @@
    entry-0002 size 32
 
   $ hg debug-revlog-index --verbose -c
-     rev linkrev       nodeid p1-rev    p1-nodeid    p2-nodeid
-       0       0 7049e48789d7     -1 000000000000 000000000000
-       1       1 2707720c6597      0 7049e48789d7 000000000000
-       2       2 40f977031323      1 2707720c6597 000000000000
+     rev linkrev       nodeid p1-rev    p1-nodeid p2-rev    p2-nodeid
+       0       0 7049e48789d7     -1 000000000000     -1 000000000000
+       1       1 2707720c6597      0 7049e48789d7     -1 000000000000
+       2       2 40f977031323      1 2707720c6597     -1 000000000000
 
   $ hg debug-revlog-index --verbose -m
-     rev linkrev       nodeid p1-rev    p1-nodeid    p2-nodeid
-       0       0 b85d294330e3     -1 000000000000 000000000000
-       1       1 1a0aec305c63      0 b85d294330e3 000000000000
-       2       2 104258a4f75f      1 1a0aec305c63 000000000000
+     rev linkrev       nodeid p1-rev    p1-nodeid p2-rev    p2-nodeid
+       0       0 b85d294330e3     -1 000000000000     -1 000000000000
+       1       1 1a0aec305c63      0 b85d294330e3     -1 000000000000
+       2       2 104258a4f75f      1 1a0aec305c63     -1 000000000000
 
 Check upgrade behavior
 ======================