Mercurial > public > mercurial-scm > hg
diff mercurial/cmdutil.py @ 38342:b8f45fc27370
grep: adds allfiles mode
Adds an allfiles flag that lets you grep on all files in the revision
and not just the one that were modified in that changeset.
This would work on a single revision and get all the files that were
there in that revision. So it's like grepping on a previous state.
Using this with wdir() :: `hg grep -r "wdir()" --allfiles` is what the
default behavior is desired for grep.
Support for multiple revisions to be added later.
Differential Revision: https://phab.mercurial-scm.org/D3728
author | Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com> |
---|---|
date | Wed, 13 Jun 2018 16:22:54 +0530 |
parents | 50f5fc232c16 |
children | 89db59e5cf3e |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed Jun 13 22:50:32 2018 +0530 +++ b/mercurial/cmdutil.py Wed Jun 13 16:22:54 2018 +0530 @@ -1881,10 +1881,13 @@ yielding each context, the iterator will first call the prepare function on each context in the window in forward order.''' + allfiles = opts.get('allfiles') follow = opts.get('follow') or opts.get('follow_first') revs = _walkrevs(repo, opts) if not revs: return [] + if allfiles and len(revs) > 1: + raise error.Abort(_("multiple revisions not supported with --allfiles")) wanted = set() slowpath = match.anypats() or (not match.always() and opts.get('removed')) fncache = {} @@ -1990,7 +1993,11 @@ ctx = change(rev) if not fns: def fns_generator(): - for f in ctx.files(): + if allfiles: + fiter = iter(ctx) + else: + fiter = ctx.files() + for f in fiter: if match(f): yield f fns = fns_generator()