diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -54,8 +54,8 @@ def countrate(ui, repo, amap, *pats, **o df = util.matchdate(opts['date']) get = util.cachefunc(lambda r: repo[r]) - changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) - for st, rev, fns in changeiter: + m = cmdutil.match(repo, pats, opts) + for st, rev, fns in cmdutil.walkchangerevs(ui, repo, m, get, opts): if not st == 'add': continue diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1024,9 +1024,9 @@ def finddate(ui, repo, date): """Find the tipmost changeset that matches the given date spec""" df = util.matchdate(date) get = util.cachefunc(lambda r: repo[r]) - changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None}) + m = matchall(repo) results = {} - for st, rev, fns in changeiter: + for st, rev, fns in walkchangerevs(ui, repo, m, get, {'rev':None}): if st == 'add': d = get(rev).date() if df(d[0]): @@ -1039,7 +1039,7 @@ def finddate(ui, repo, date): raise util.Abort(_("revision matching date not found")) -def walkchangerevs(ui, repo, pats, change, opts): +def walkchangerevs(ui, repo, match, change, opts): '''Iterate over files and the revs in which they changed. Callers most commonly need to iterate backwards over the history @@ -1050,8 +1050,8 @@ def walkchangerevs(ui, repo, pats, chang window, we first walk forwards to gather data, then in the desired order (usually backwards) to display it. - This function returns an (iterator, matchfn) tuple. The iterator - yields 3-tuples. They will be of one of the following forms: + This function returns an iterator. The iterator yields 3-tuples. + They will be of one of the following forms: "window", incrementing, lastrev: stepping through a window, positive if walking forwards through revs, last rev in the @@ -1078,11 +1078,10 @@ def walkchangerevs(ui, repo, pats, chang if windowsize < sizelimit: windowsize *= 2 - m = match(repo, pats, opts) follow = opts.get('follow') or opts.get('follow_first') if not len(repo): - return [], m + return [] if follow: defrange = '%s:0' % repo['.'].rev() @@ -1090,10 +1089,10 @@ def walkchangerevs(ui, repo, pats, chang defrange = '-1:0' revs = revrange(repo, opts['rev'] or [defrange]) wanted = set() - slowpath = m.anypats() or (m.files() and opts.get('removed')) + slowpath = match.anypats() or (match.files() and opts.get('removed')) fncache = {} - if not slowpath and not m.files(): + if not slowpath and not match.files(): # No files, no patterns. Display all revs. wanted = set(revs) copies = [] @@ -1117,7 +1116,7 @@ def walkchangerevs(ui, repo, pats, chang if rev[0] < cl_count: yield rev def iterfiles(): - for filename in m.files(): + for filename in match.files(): yield filename, None for filename_node in copies: yield filename_node @@ -1157,7 +1156,7 @@ def walkchangerevs(ui, repo, pats, chang yield change(j) for ctx in changerevgen(): - matches = filter(m, ctx.files()) + matches = filter(match, ctx.files()) if matches: fncache[ctx.rev()] = matches wanted.add(ctx.rev()) @@ -1210,7 +1209,7 @@ def walkchangerevs(ui, repo, pats, chang wanted.discard(x) def iterate(): - if follow and not m.files(): + if follow and not match.files(): ff = followfilter(onlyfirst=opts.get('follow_first')) def want(rev): return ff.match(rev) and rev in wanted @@ -1226,13 +1225,13 @@ def walkchangerevs(ui, repo, pats, chang if not fns: def fns_generator(): for f in change(rev).files(): - if m(f): + if match(f): yield f fns = fns_generator() yield 'add', rev, fns for rev in nrevs: yield 'iter', rev, None - return iterate(), m + return iterate() def commit(ui, repo, commitfunc, pats, opts): '''commit the specified files or all outstanding changes''' diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1289,10 +1289,10 @@ def grep(ui, repo, pattern, *pats, **opt skip = {} revfiles = {} get = util.cachefunc(lambda r: repo[r]) - changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) + matchfn = cmdutil.match(repo, pats, opts) found = False follow = opts.get('follow') - for st, rev, fns in changeiter: + for st, rev, fns in cmdutil.walkchangerevs(ui, repo, matchfn, get, opts): if st == 'window': matches.clear() revfiles.clear() @@ -1980,8 +1980,7 @@ def log(ui, repo, *pats, **opts): """ get = util.cachefunc(lambda r: repo[r]) - changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) - + matchfn = cmdutil.match(repo, pats, opts) limit = cmdutil.loglimit(opts) count = 0 @@ -2028,7 +2027,7 @@ 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 changeiter: + for st, rev, fns in cmdutil.walkchangerevs(ui, repo, matchfn, get, opts): if st == 'add': parents = [p for p in repo.changelog.parentrevs(rev) if p != nullrev]