diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2536,24 +2536,36 @@ def debugrevlog(ui, repo, file_=None, ** if opts.get("dump"): numrevs = len(r) ui.write("# rev p1rev p2rev start end deltastart base p1 p2" - " rawsize totalsize compression heads\n") + " rawsize totalsize compression heads chainlen\n") ts = 0 heads = set() + rindex = r.index + + def chainbaseandlen(rev): + clen = 0 + base = rindex[rev][3] + while base != rev: + clen += 1 + rev = base + base = rindex[rev][3] + return base, clen + for rev in xrange(numrevs): dbase = r.deltaparent(rev) if dbase == -1: dbase = rev - cbase = r.chainbase(rev) + cbase, clen = chainbaseandlen(rev) p1, p2 = r.parentrevs(rev) rs = r.rawsize(rev) ts = ts + rs heads -= set(r.parentrevs(rev)) heads.add(rev) - ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d %11d %5d\n" % + ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d " + "%11d %5d %8d\n" % (rev, p1, p2, r.start(rev), r.end(rev), r.start(dbase), r.start(cbase), r.start(p1), r.start(p2), - rs, ts, ts / r.end(rev), len(heads))) + rs, ts, ts / r.end(rev), len(heads), clen)) return 0 v = r.version diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -88,11 +88,11 @@ Killing a single changeset with replacem $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden 2:245bde4270cd add original_c $ hg debugrevlog -cd - # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads - 0 -1 -1 0 59 0 0 0 0 58 58 0 1 - 1 0 -1 59 118 59 59 0 0 58 116 0 1 - 2 1 -1 118 204 59 59 59 0 76 192 0 1 - 3 1 -1 204 271 204 204 59 0 66 258 0 2 + # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen + 0 -1 -1 0 59 0 0 0 0 58 58 0 1 0 + 1 0 -1 59 118 59 59 0 0 58 116 0 1 0 + 2 1 -1 118 204 59 59 59 0 76 192 0 1 1 + 3 1 -1 204 271 204 204 59 0 66 258 0 2 0 $ hg debugobsolete 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:44 1970 -0000) {'user': 'test'}