Mercurial > hg
changeset 11336:3dfbe26cfded
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text
Mainly useful for reusing DAGs somewhere else, for example for attaching
them to a bug report, or for importing them into other environments
(like my test environment for incoming/outgoing discovery).
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Thu, 10 Jun 2010 11:48:45 +0200 |
parents | 3201ff1459dd |
children | 0f3c8a47960e |
files | mercurial/commands.py tests/test-debugcomplete.out |
diffstat | 2 files changed, 65 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Jun 10 11:48:15 2010 +0200 +++ b/mercurial/commands.py Thu Jun 10 11:48:45 2010 +0200 @@ -14,6 +14,7 @@ import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server import merge as mergemod import minirst, revset +import dagparser # Commands start here, listed alphabetically @@ -1023,6 +1024,59 @@ ui.write(' source %s\n' % v[0]) ui.write(' revision %s\n' % v[1]) +def debugdag(ui, repo, file_=None, *revs, **opts): + """format the changelog or an index DAG as a concise textual description + + If you pass a revlog index, the revlog's DAG is emitted. If you list + revision numbers, they get labelled in the output as rN. + + Otherwise, the changelog DAG of the current repo is emitted. + """ + spaces = opts.get('spaces') + dots = opts.get('dots') + if file_: + rlog = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) + revs = set((int(r) for r in revs)) + def events(): + for r in rlog: + yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1))) + if r in revs: + yield 'l', (r, "r%i" % r) + elif repo: + cl = repo.changelog + tags = opts.get('tags') + branches = opts.get('branches') + if tags: + labels = {} + for l, n in repo.tags().items(): + labels.setdefault(cl.rev(n), []).append(l) + def events(): + b = "default" + for r in cl: + if branches: + newb = cl.read(cl.node(r))[5]['branch'] + if newb != b: + yield 'a', newb + b = newb + yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1))) + if tags: + ls = labels.get(r) + if ls: + for l in ls: + yield 'l', (r, l) + else: + raise util.Abort(_('need repo for changelog dag')) + + for line in dagparser.dagtextlines(events(), + addspaces=spaces, + wraplabels=True, + wrapannotations=True, + wrapnonlinear=dots, + usedots=dots, + maxlinewidth=70): + ui.write(line) + ui.write("\n") + def debugdata(ui, file_, rev): """dump the contents of a data file revision""" r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i") @@ -3875,6 +3929,14 @@ (debugcomplete, [('o', 'options', None, _('show the command options'))], _('[-o] CMD')), + "debugdag": + (debugdag, + [('t', 'tags', None, _('use tags as labels')), + ('b', 'branches', None, _('annotate with branch names')), + ('', 'dots', None, _('use dots for runs')), + ('s', 'spaces', None, _('separate elements by spaces')), + ], + _('[OPTION]... [FILE [REV]...]')), "debugdate": (debugdate, [('e', 'extended', None, _('try extended date formats'))], @@ -4233,4 +4295,4 @@ norepo = ("clone init version help debugcommands debugcomplete debugdata" " debugindex debugindexdot debugdate debuginstall debugfsinfo") -optionalrepo = ("identify paths serve showconfig debugancestor") +optionalrepo = ("identify paths serve showconfig debugancestor debugdag")
--- a/tests/test-debugcomplete.out Thu Jun 10 11:48:15 2010 +0200 +++ b/tests/test-debugcomplete.out Thu Jun 10 11:48:45 2010 +0200 @@ -65,6 +65,7 @@ debugcommands debugcomplete debugconfig +debugdag debugdata debugdate debugfsinfo @@ -194,6 +195,7 @@ debugcheckstate: debugcommands: debugcomplete: options +debugdag: tags, branches, dots, spaces debugdata: debugdate: extended debugfsinfo: