Mercurial > hg
changeset 8836:11ff34956ee7
graphmod/graphlog: move log walks to graphmod
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Fri, 19 Jun 2009 13:14:01 +0200 |
parents | ec5483efc31f |
children | d8e3a98018cb |
files | hgext/graphlog.py mercurial/graphmod.py |
diffstat | 2 files changed, 37 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/graphlog.py Thu May 14 17:32:31 2009 +0200 +++ b/hgext/graphlog.py Fri Jun 19 13:14:01 2009 +0200 @@ -18,41 +18,7 @@ from mercurial.i18n import _ from mercurial.node import nullrev from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions -from mercurial import hg, url, util - -def revisions(repo, start, stop): - """cset DAG generator yielding (rev, node, [parents]) tuples - - This generator function walks through the revision history from revision - start to revision stop (which must be less than or equal to start). - """ - assert start >= stop - cur = start - while cur >= stop: - ctx = repo[cur] - parents = [p.rev() for p in ctx.parents() if p.rev() != nullrev] - parents.sort() - yield (ctx, parents) - cur -= 1 - -def filerevs(repo, path, start, stop): - """file cset DAG generator yielding (rev, node, [parents]) tuples - - This generator function walks through the revision history of a single - file from revision start to revision stop (which must be less than or - equal to start). - """ - assert start >= stop - filerev = len(repo.file(path)) - 1 - while filerev >= 0: - fctx = repo.filectx(path, fileid=filerev) - parents = [f.linkrev() for f in fctx.parents() if f.path() == path] - parents.sort() - if fctx.rev() <= start: - yield (fctx, parents) - if fctx.rev() <= stop: - break - filerev -= 1 +from mercurial import hg, url, util, graphmod def grapher(nodes): """grapher for asciigraph on a list of nodes and their parents @@ -278,9 +244,9 @@ if path: path = util.canonpath(repo.root, os.getcwd(), path) if path: # could be reset in canonpath - revdag = filerevs(repo, path, start, stop) + revdag = graphmod.filerevs(repo, path, start, stop) else: - revdag = revisions(repo, start, stop) + revdag = graphmod.revisions(repo, start, stop) graphdag = graphabledag(ui, repo, revdag, opts) ascii(ui, grapher(graphdag))
--- a/mercurial/graphmod.py Thu May 14 17:32:31 2009 +0200 +++ b/mercurial/graphmod.py Fri Jun 19 13:14:01 2009 +0200 @@ -8,6 +8,40 @@ from node import nullrev +def revisions(repo, start, stop): + """cset DAG generator yielding (rev, node, [parents]) tuples + + This generator function walks through the revision history from revision + start to revision stop (which must be less than or equal to start). + """ + assert start >= stop + cur = start + while cur >= stop: + ctx = repo[cur] + parents = [p.rev() for p in ctx.parents() if p.rev() != nullrev] + parents.sort() + yield (ctx, parents) + cur -= 1 + +def filerevs(repo, path, start, stop): + """file cset DAG generator yielding (rev, node, [parents]) tuples + + This generator function walks through the revision history of a single + file from revision start to revision stop (which must be less than or + equal to start). + """ + assert start >= stop + filerev = len(repo.file(path)) - 1 + while filerev >= 0: + fctx = repo.filectx(path, fileid=filerev) + parents = [f.linkrev() for f in fctx.parents() if f.path() == path] + parents.sort() + if fctx.rev() <= start: + yield (fctx, parents) + if fctx.rev() <= stop: + break + filerev -= 1 + def graph(repo, start_rev, stop_rev): """incremental revision grapher