# HG changeset patch # User Matt Mackall # Date 2009-10-25 23:43:59 # Node ID 96fe91be9c1e763fef7f43d1a3c08b8130d58caf # Parent e4de75343743f8ea3355b862d476ae2dadaf8100 walkchangerevs: yield contexts diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -55,12 +55,11 @@ def countrate(ui, repo, amap, *pats, **o 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 diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1217,15 +1217,16 @@ def walkchangerevs(ui, repo, match, chan 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): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1292,9 +1292,9 @@ def grep(ui, repo, pattern, *pats, **opt 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 @@ def grep(ui, repo, pattern, *pats, **opt 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 @@ def log(ui, repo, *pats, **opts): 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 @@ def log(ui, repo, *pats, **opts): 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 @@ def log(ui, repo, *pats, **opts): 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):