comparison mercurial/commands.py @ 23547:21446f4d5c62

debugindex: respect --debug flag to show full nodeids
author Kyle Lippincott <spectral@google.com>
date Sat, 13 Dec 2014 13:56:05 -0800
parents ccfb56450f21
children 7cfe58983bff
comparison
equal deleted inserted replaced
23546:deabbe7ed54b 23547:21446f4d5c62
2171 if generaldelta: 2171 if generaldelta:
2172 basehdr = ' delta' 2172 basehdr = ' delta'
2173 else: 2173 else:
2174 basehdr = ' base' 2174 basehdr = ' base'
2175 2175
2176 if ui.debugflag:
2177 shortfn = hex
2178 else:
2179 shortfn = short
2180
2181 # There might not be anything in r, so have a sane default
2182 idlen = 12
2183 for i in r:
2184 idlen = len(shortfn(r.node(i)))
2185 break
2186
2176 if format == 0: 2187 if format == 0:
2177 ui.write(" rev offset length " + basehdr + " linkrev" 2188 ui.write(" rev offset length " + basehdr + " linkrev"
2178 " nodeid p1 p2\n") 2189 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
2179 elif format == 1: 2190 elif format == 1:
2180 ui.write(" rev flag offset length" 2191 ui.write(" rev flag offset length"
2181 " size " + basehdr + " link p1 p2" 2192 " size " + basehdr + " link p1 p2"
2182 " nodeid\n") 2193 " %s\n" % "nodeid".rjust(idlen))
2183 2194
2184 for i in r: 2195 for i in r:
2185 node = r.node(i) 2196 node = r.node(i)
2186 if generaldelta: 2197 if generaldelta:
2187 base = r.deltaparent(i) 2198 base = r.deltaparent(i)
2192 pp = r.parents(node) 2203 pp = r.parents(node)
2193 except Exception: 2204 except Exception:
2194 pp = [nullid, nullid] 2205 pp = [nullid, nullid]
2195 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( 2206 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2196 i, r.start(i), r.length(i), base, r.linkrev(i), 2207 i, r.start(i), r.length(i), base, r.linkrev(i),
2197 short(node), short(pp[0]), short(pp[1]))) 2208 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2198 elif format == 1: 2209 elif format == 1:
2199 pr = r.parentrevs(i) 2210 pr = r.parentrevs(i)
2200 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( 2211 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2201 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), 2212 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2202 base, r.linkrev(i), pr[0], pr[1], short(node))) 2213 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
2203 2214
2204 @command('debugindexdot', [], _('FILE'), optionalrepo=True) 2215 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
2205 def debugindexdot(ui, repo, file_): 2216 def debugindexdot(ui, repo, file_):
2206 """dump an index DAG as a graphviz dot file""" 2217 """dump an index DAG as a graphviz dot file"""
2207 r = None 2218 r = None