Mercurial > hg
comparison hgext/graphlog.py @ 8837:d8e3a98018cb
graphmod/graphlog: extract nodelistwalk
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Fri, 19 Jun 2009 13:14:45 +0200 |
parents | 11ff34956ee7 |
children | e89b05308d69 |
comparison
equal
deleted
inserted
replaced
8836:11ff34956ee7 | 8837:d8e3a98018cb |
---|---|
10 This extension adds a --graph option to the incoming, outgoing and log | 10 This extension adds a --graph option to the incoming, outgoing and log |
11 commands. When this options is given, an ASCII representation of the | 11 commands. When this options is given, an ASCII representation of the |
12 revision graph is also shown. | 12 revision graph is also shown. |
13 ''' | 13 ''' |
14 | 14 |
15 import os | 15 import os, sys |
16 from mercurial.cmdutil import revrange, show_changeset | 16 from mercurial.cmdutil import revrange, show_changeset |
17 from mercurial.commands import templateopts | 17 from mercurial.commands import templateopts |
18 from mercurial.i18n import _ | 18 from mercurial.i18n import _ |
19 from mercurial.node import nullrev | 19 from mercurial.node import nullrev |
20 from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions | 20 from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions |
250 | 250 |
251 graphdag = graphabledag(ui, repo, revdag, opts) | 251 graphdag = graphabledag(ui, repo, revdag, opts) |
252 ascii(ui, grapher(graphdag)) | 252 ascii(ui, grapher(graphdag)) |
253 | 253 |
254 def graphrevs(repo, nodes, opts): | 254 def graphrevs(repo, nodes, opts): |
255 include = set(nodes) | |
256 limit = cmdutil.loglimit(opts) | 255 limit = cmdutil.loglimit(opts) |
257 count = 0 | 256 nodes.reverse() |
258 for node in reversed(nodes): | 257 if limit < sys.maxint: |
259 if count >= limit: | 258 nodes = nodes[:limit] |
260 break | 259 return graphmod.nodes(repo, nodes) |
261 ctx = repo[node] | |
262 parents = [p.rev() for p in ctx.parents() if p.node() in include] | |
263 parents.sort() | |
264 yield (ctx, parents) | |
265 count += 1 | |
266 | 260 |
267 def graphabledag(ui, repo, revdag, opts): | 261 def graphabledag(ui, repo, revdag, opts): |
268 showparents = [ctx.node() for ctx in repo[None].parents()] | 262 showparents = [ctx.node() for ctx in repo[None].parents()] |
269 displayer = show_changeset(ui, repo, opts, buffered=True) | 263 displayer = show_changeset(ui, repo, opts, buffered=True) |
270 for (ctx, parents) in revdag: | 264 for (ctx, parents) in revdag: |