Patchwork debugindex: respect --debug flag to show full nodeids

login
register
mail settings
Submitter Kyle Lippincott
Date Dec. 13, 2014, 9:57 p.m.
Message ID <e8735f2513b4b0217ffd.1418507874@dragonair.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7078/
State Superseded
Headers show

Comments

Kyle Lippincott - Dec. 13, 2014, 9:57 p.m.
# HG changeset patch
# User Kyle Lippincott <spectral@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
Kyle Lippincott - Dec. 13, 2014, 10:11 p.m.
marmoute just suggested I add tests for this, so will be sending an updated
version soon.

On Sat, Dec 13, 2014 at 1:57 PM, Kyle Lippincott <spectral@google.com>
wrote:
>
> # HG changeset patch
> # User Kyle Lippincott <spectral@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_):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

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_):