walkchangerevs: yield contexts
authorMatt Mackall <mpm@selenic.com>
Sun, 25 Oct 2009 18:43:59 -0500
changeset 9654 96fe91be9c1e
parent 9653 e4de75343743
child 9655 6d7d3f849062
walkchangerevs: yield contexts
hgext/churn.py
mercurial/cmdutil.py
mercurial/commands.py
--- a/hgext/churn.py	Sun Oct 25 18:43:58 2009 -0500
+++ b/hgext/churn.py	Sun Oct 25 18:43:59 2009 -0500
@@ -55,12 +55,11 @@
 
     get = util.cachefunc(lambda r: repo[r])
     m = cmdutil.match(repo, pats, opts)
-    for st, rev, fns in cmdutil.walkchangerevs(ui, repo, m, get, opts):
-
+    for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, m, get, opts):
         if not st == 'add':
             continue
 
-        ctx = get(rev)
+        rev = ctx.rev()
         if df and not df(ctx.date()[0]): # doesn't match date format
             continue
 
--- a/mercurial/cmdutil.py	Sun Oct 25 18:43:58 2009 -0500
+++ b/mercurial/cmdutil.py	Sun Oct 25 18:43:59 2009 -0500
@@ -1217,15 +1217,16 @@
             nrevs = [rev for rev in revs[i:i+window] if want(rev)]
             for rev in sorted(nrevs):
                 fns = fncache.get(rev)
+                ctx = change(rev)
                 if not fns:
                     def fns_generator():
-                        for f in change(rev).files():
+                        for f in ctx.files():
                             if match(f):
                                 yield f
                     fns = fns_generator()
-                yield 'add', rev, fns
+                yield 'add', ctx, fns
             for rev in nrevs:
-                yield 'iter', rev, None
+                yield 'iter', change(rev), None
     return iterate()
 
 def commit(ui, repo, commitfunc, pats, opts):
--- a/mercurial/commands.py	Sun Oct 25 18:43:58 2009 -0500
+++ b/mercurial/commands.py	Sun Oct 25 18:43:59 2009 -0500
@@ -1292,9 +1292,9 @@
     matchfn = cmdutil.match(repo, pats, opts)
     found = False
     follow = opts.get('follow')
-    for st, rev, fns in cmdutil.walkchangerevs(ui, repo, matchfn, get, opts):
+    for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, get, opts):
         if st == 'add':
-            ctx = get(rev)
+            rev = ctx.rev()
             pctx = ctx.parents()[0]
             parent = pctx.rev()
             matches.setdefault(rev, {})
@@ -1328,6 +1328,7 @@
                     except error.LookupError:
                         pass
         elif st == 'iter':
+            rev = ctx.rev()
             parent = get(rev).parents()[0].rev()
             for fn in sorted(revfiles.get(rev, [])):
                 states = matches[rev][fn]
@@ -2026,8 +2027,9 @@
     only_branches = opts.get('only_branch')
 
     displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
-    for st, rev, fns in cmdutil.walkchangerevs(ui, repo, matchfn, get, opts):
+    for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, get, opts):
         if st == 'add':
+            rev = ctx.rev()
             parents = [p for p in repo.changelog.parentrevs(rev)
                        if p != nullrev]
             if opts.get('no_merges') and len(parents) == 2:
@@ -2035,7 +2037,6 @@
             if opts.get('only_merges') and len(parents) != 2:
                 continue
 
-            ctx = get(rev)
             if only_branches and ctx.branch() not in only_branches:
                 continue
 
@@ -2068,7 +2069,7 @@
 
         elif st == 'iter':
             if count == limit: break
-            if displayer.flush(rev):
+            if displayer.flush(ctx.rev()):
                 count += 1
 
 def manifest(ui, repo, node=None, rev=None):