diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1260,26 +1260,43 @@ def debugdate(ui, date, range=None, **op 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 @@ table = { _('[-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]')), diff --git a/tests/test-clone-r.t b/tests/test-clone-r.t --- a/tests/test-clone-r.t +++ b/tests/test-clone-r.t @@ -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 diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t --- a/tests/test-debugcomplete.t +++ b/tests/test-debugcomplete.t @@ -212,7 +212,7 @@ Show all commands + options debugdata: debugdate: extended debugfsinfo: - debugindex: + debugindex: format debugindexdot: debuginstall: debugpushkey: