# HG changeset patch # User Peter Arrenbrecht # Date 1242450701 -7200 # Node ID e89b05308d6969a356d210c0c662f1d4e8c18a20 # Parent d8e3a98018cb1610c78e9d6d828183ac6e4f777b graphlog: move and rename graphabledag to asciiformat diff -r d8e3a98018cb -r e89b05308d69 hgext/graphlog.py --- 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: