changeset 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
files hgext/graphlog.py mercurial/graphmod.py
diffstat 2 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/graphlog.py	Fri Jun 19 13:14:01 2009 +0200
+++ b/hgext/graphlog.py	Fri Jun 19 13:14:45 2009 +0200
@@ -12,7 +12,7 @@
 revision graph is also shown.
 '''
 
-import os
+import os, sys
 from mercurial.cmdutil import revrange, show_changeset
 from mercurial.commands import templateopts
 from mercurial.i18n import _
@@ -252,17 +252,11 @@
     ascii(ui, grapher(graphdag))
 
 def graphrevs(repo, nodes, opts):
-    include = set(nodes)
     limit = cmdutil.loglimit(opts)
-    count = 0
-    for node in reversed(nodes):
-        if count >= limit:
-            break
-        ctx = repo[node]
-        parents = [p.rev() for p in ctx.parents() if p.node() in include]
-        parents.sort()
-        yield (ctx, parents)
-        count += 1
+    nodes.reverse()
+    if limit < sys.maxint:
+        nodes = nodes[:limit]
+    return graphmod.nodes(repo, nodes)
 
 def graphabledag(ui, repo, revdag, opts):
     showparents = [ctx.node() for ctx in repo[None].parents()]
--- a/mercurial/graphmod.py	Fri Jun 19 13:14:01 2009 +0200
+++ b/mercurial/graphmod.py	Fri Jun 19 13:14:45 2009 +0200
@@ -42,6 +42,14 @@
             break
         filerev -= 1
 
+def nodes(repo, nodes):
+    include = set(nodes)
+    for node in nodes:
+        ctx = repo[node]
+        parents = [p.rev() for p in ctx.parents() if p.node() in include]
+        parents.sort()
+        yield (ctx, parents)
+
 def graph(repo, start_rev, stop_rev):
     """incremental revision grapher