[PATCH] debugindex: respect --debug flag to show full nodeids

Kyle Lippincott spectral at google.com
Sat Dec 13 21:57:54 UTC 2014


# HG changeset patch
# User Kyle Lippincott <spectral at google.com>
# Date 1418507765 28800
#      Sat Dec 13 13:56:05 2014 -0800
# Node ID e8735f2513b4b0217ffd302c9212a21bf56daa09
# Parent  e88a634e0195ef2b260f40786505727c80dbdbd5
debugindex: respect --debug flag to show full nodeids

diff -r e88a634e0195 -r e8735f2513b4 mercurial/commands.py
--- a/mercurial/commands.py	Tue Sep 30 17:13:54 2014 -0700
+++ b/mercurial/commands.py	Sat Dec 13 13:56:05 2014 -0800
@@ -2164,9 +2164,20 @@
     else:
         basehdr = '  base'
 
+    if ui.debugflag:
+        shortfn = hex
+    else:
+        shortfn = short
+
+    # There might not be anything in r, so have a sane default
+    idlen = 12
+    for i in r:
+        idlen = len(shortfn(r.node(i)))
+        break
+
     if format == 0:
         ui.write("   rev    offset  length " + basehdr + " linkrev"
-                 " nodeid       p1           p2\n")
+                 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
     elif format == 1:
         ui.write("   rev flag   offset   length"
                  "     size " + basehdr + "   link     p1     p2"
@@ -2185,12 +2196,12 @@
                 pp = [nullid, nullid]
             ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
                     i, r.start(i), r.length(i), base, r.linkrev(i),
-                    short(node), short(pp[0]), short(pp[1])))
+                    shortfn(node), shortfn(pp[0]), shortfn(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),
-                    base, r.linkrev(i), pr[0], pr[1], short(node)))
+                    base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
 
 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
 def debugindexdot(ui, repo, file_):


More information about the Mercurial-devel mailing list