Mercurial > hg-stable
changeset 8838:e89b05308d69
graphlog: move and rename graphabledag to asciiformat
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Sat, 16 May 2009 07:11:41 +0200 |
parents | d8e3a98018cb |
children | bbfa21b6f18a |
files | hgext/graphlog.py |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/graphlog.py Fri Jun 19 13:14:45 2009 +0200 +++ b/hgext/graphlog.py Sat May 16 07:11:41 2009 +0200 @@ -20,6 +20,16 @@ from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions from mercurial import hg, url, util, graphmod +def asciiformat(ui, repo, revdag, opts): + """formats a changelog DAG walk for ASCII output""" + showparents = [ctx.node() for ctx in repo[None].parents()] + displayer = show_changeset(ui, repo, opts, buffered=True) + for (ctx, parents) in revdag: + displayer.show(ctx) + lines = displayer.hunk.pop(ctx.rev()).split('\n')[:-1] + char = ctx.node() in showparents and '@' or 'o' + yield (ctx.rev(), parents, char, lines) + def grapher(nodes): """grapher for asciigraph on a list of nodes and their parents @@ -248,7 +258,7 @@ else: revdag = graphmod.revisions(repo, start, stop) - graphdag = graphabledag(ui, repo, revdag, opts) + graphdag = asciiformat(ui, repo, revdag, opts) ascii(ui, grapher(graphdag)) def graphrevs(repo, nodes, opts): @@ -258,15 +268,6 @@ nodes = nodes[:limit] return graphmod.nodes(repo, nodes) -def graphabledag(ui, repo, revdag, opts): - showparents = [ctx.node() for ctx in repo[None].parents()] - displayer = show_changeset(ui, repo, opts, buffered=True) - for (ctx, parents) in revdag: - displayer.show(ctx) - lines = displayer.hunk.pop(ctx.rev()).split('\n')[:-1] - char = ctx.node() in showparents and '@' or 'o' - yield (ctx.rev(), parents, char, lines) - def goutgoing(ui, repo, dest=None, **opts): """show the outgoing changesets alongside an ASCII revision graph @@ -292,7 +293,7 @@ o = repo.changelog.nodesbetween(o, revs)[0] revdag = graphrevs(repo, o, opts) - graphdag = graphabledag(ui, repo, revdag, opts) + graphdag = asciiformat(ui, repo, revdag, opts) ascii(ui, grapher(graphdag)) def gincoming(ui, repo, source="default", **opts): @@ -341,7 +342,7 @@ chlist = other.changelog.nodesbetween(incoming, revs)[0] revdag = graphrevs(other, chlist, opts) - graphdag = graphabledag(ui, repo, revdag, opts) + graphdag = asciiformat(ui, repo, revdag, opts) ascii(ui, grapher(graphdag)) finally: