changeset 12893:15ca4bfecfe3 stable

debugindex: add --format flag to allow debugging parentdelta -f 1 shows extra data from revlogv1 (aka revlogng) including flags and size (based on a patch by Pradeepkumar Gayam <in3xes@gmail.com>)
author Matt Mackall <mpm@selenic.com>
date Sat, 30 Oct 2010 02:47:35 -0500
parents 919c440868d9
children bc91a79fa3d0 80076785e150
files mercurial/commands.py tests/test-clone-r.t tests/test-debugcomplete.t
diffstat 3 files changed, 37 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Oct 29 00:57:34 2010 -0500
+++ b/mercurial/commands.py	Sat Oct 30 02:47:35 2010 -0500
@@ -1260,26 +1260,43 @@
         m = util.matchdate(range)
         ui.write("match: %s\n" % m(d[0]))
 
-def debugindex(ui, repo, file_):
+def debugindex(ui, repo, file_, **opts):
     """dump the contents of an index file"""
     r = None
     if repo:
         filelog = repo.file(file_)
         if len(filelog):
             r = filelog
+
+    format = opts.get('format', 0)
+    if format not in (0, 1):
+        raise util.abort("unknown format %d" % format)
+
     if not r:
         r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
-    ui.write("   rev    offset  length   base linkrev"
-             " nodeid       p1           p2\n")
+
+    if format == 0:
+        ui.write("   rev    offset  length   base linkrev"
+                 " nodeid       p1           p2\n")
+    elif format == 1:
+        ui.write("   rev flag   offset   length"
+                 "     size   base   link     p1     p2       nodeid\n")
+
     for i in r:
         node = r.node(i)
-        try:
-            pp = r.parents(node)
-        except:
-            pp = [nullid, nullid]
-        ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
-                i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
-            short(node), short(pp[0]), short(pp[1])))
+        if format == 0:
+            try:
+                pp = r.parents(node)
+            except:
+                pp = [nullid, nullid]
+            ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
+                    i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
+                    short(node), short(pp[0]), short(pp[1])))
+        elif format == 1:
+            pr = r.parentrevs(i)
+            ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
+                    i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
+                    r.base(i), r.linkrev(i), pr[0], pr[1], short(node)))
 
 def debugindexdot(ui, repo, file_):
     """dump an index DAG as a graphviz dot file"""
@@ -4139,7 +4156,9 @@
          _('[-e] DATE [RANGE]')),
     "debugdata": (debugdata, [], _('FILE REV')),
     "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
-    "debugindex": (debugindex, [], _('FILE')),
+    "debugindex": (debugindex,
+                   [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
+                   _('FILE')),
     "debugindexdot": (debugindexdot, [], _('FILE')),
     "debuginstall": (debuginstall, [], ''),
     "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')),
--- a/tests/test-clone-r.t	Fri Oct 29 00:57:34 2010 -0500
+++ b/tests/test-clone-r.t	Sat Oct 30 02:47:35 2010 -0500
@@ -37,12 +37,12 @@
   $ hg mv afile anotherfile
   $ hg commit -m "0.3m"
 
-  $ hg debugindex .hg/store/data/afile.i
-     rev    offset  length   base linkrev nodeid       p1           p2
-       0         0       3      0       0 362fef284ce2 000000000000 000000000000
-       1         3       5      1       1 125144f7e028 362fef284ce2 000000000000
-       2         8       7      2       2 4c982badb186 125144f7e028 000000000000
-       3        15       9      3       3 19b1fc555737 4c982badb186 000000000000
+  $ hg debugindex -f 1 .hg/store/data/afile.i
+     rev flag   offset   length     size   base   link     p1     p2       nodeid
+       0 0000        0        3        2      0      0     -1     -1 362fef284ce2
+       1 0000        3        5        4      1      1      0     -1 125144f7e028
+       2 0000        8        7        6      2      2      1     -1 4c982badb186
+       3 0000       15        9        8      3      3      2     -1 19b1fc555737
 
   $ hg debugindex .hg/store/data/adifferentfile.i
      rev    offset  length   base linkrev nodeid       p1           p2
--- a/tests/test-debugcomplete.t	Fri Oct 29 00:57:34 2010 -0500
+++ b/tests/test-debugcomplete.t	Sat Oct 30 02:47:35 2010 -0500
@@ -212,7 +212,7 @@
   debugdata: 
   debugdate: extended
   debugfsinfo: 
-  debugindex: 
+  debugindex: format
   debugindexdot: 
   debuginstall: 
   debugpushkey: