Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/cmdutil.py (22 lines) | |||
| M | tests/test-grep.t (9 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Sangeet Kumar Mishra | Jul 25 2018, 3:20 AM |
| yielding each context, the iterator will first call the prepare | yielding each context, the iterator will first call the prepare | ||||
| function on each context in the window in forward order.''' | function on each context in the window in forward order.''' | ||||
| allfiles = opts.get('all_files') | allfiles = opts.get('all_files') | ||||
| follow = opts.get('follow') or opts.get('follow_first') | follow = opts.get('follow') or opts.get('follow_first') | ||||
| revs = _walkrevs(repo, opts) | revs = _walkrevs(repo, opts) | ||||
| if not revs: | if not revs: | ||||
| return [] | return [] | ||||
| if allfiles and len(revs) > 1: | |||||
| raise error.Abort(_("multiple revisions not supported with " | |||||
| "--all-files")) | |||||
| wanted = set() | wanted = set() | ||||
| slowpath = match.anypats() or (not match.always() and opts.get('removed')) | slowpath = match.anypats() or (not match.always() and opts.get('removed')) | ||||
| fncache = {} | fncache = {} | ||||
| change = repo.__getitem__ | change = repo.__getitem__ | ||||
| # First step is to fill wanted, the set of revisions that we want to yield. | # First step is to fill wanted, the set of revisions that we want to yield. | ||||
| # When it does not induce extra cost, we also fill fncache for revisions in | # When it does not induce extra cost, we also fill fncache for revisions in | ||||
| # wanted: a cache of filenames that were changed (ctx.files()) and that | # wanted: a cache of filenames that were changed (ctx.files()) and that | ||||
| def want(rev): | def want(rev): | ||||
| return ff.match(rev) and rev in wanted | return ff.match(rev) and rev in wanted | ||||
| else: | else: | ||||
| def want(rev): | def want(rev): | ||||
| return rev in wanted | return rev in wanted | ||||
| it = iter(revs) | it = iter(revs) | ||||
| stopiteration = False | stopiteration = False | ||||
| # the files dictionary stores all the files that have been looked at | |||||
| # in the allfiles mode | |||||
| files ={} | |||||
| for windowsize in increasingwindows(): | for windowsize in increasingwindows(): | ||||
| nrevs = [] | nrevs = [] | ||||
| for i in xrange(windowsize): | for i in xrange(windowsize): | ||||
| rev = next(it, None) | rev = next(it, None) | ||||
| if rev is None: | if rev is None: | ||||
| stopiteration = True | stopiteration = True | ||||
| break | break | ||||
| elif want(rev): | elif want(rev): | ||||
| nrevs.append(rev) | nrevs.append(rev) | ||||
| for rev in sorted(nrevs): | for rev in sorted(nrevs): | ||||
| fns = fncache.get(rev) | fns = fncache.get(rev) | ||||
| ctx = change(rev) | ctx = change(rev) | ||||
| if not fns: | if not fns: | ||||
| def fns_generator(): | def fns_generator(): | ||||
| if allfiles: | if allfiles: | ||||
| fiter = iter(ctx) | for f in ctx: | ||||
| if match(f): | |||||
| if f not in files: | |||||
| files[f] = ctx | |||||
| yield f | |||||
| else: | else: | ||||
| fiter = ctx.files() | for f in ctx.files(): | ||||
| for f in fiter: | |||||
| if match(f): | if match(f): | ||||
| yield f | yield f | ||||
| fns = fns_generator() | fns = fns_generator() | ||||
| prepare(ctx, fns) | prepare(ctx, fns) | ||||
| for rev in nrevs: | for rev in nrevs: | ||||
| yield change(rev) | yield change(rev) | ||||
| if stopiteration: | if stopiteration: | ||||
| break | break | ||||
| "node": "ffffffffffffffffffffffffffffffffffffffff", | "node": "ffffffffffffffffffffffffffffffffffffffff", | ||||
| "rev": 2147483647, | "rev": 2147483647, | ||||
| "texts": [{"matched": true, "text": "some"}, {"matched": false, "text": " text"}], | "texts": [{"matched": true, "text": "some"}, {"matched": false, "text": " text"}], | ||||
| "user": "test" | "user": "test" | ||||
| } | } | ||||
| ] | ] | ||||
| $ cd .. | $ cd .. | ||||
| test -rMULTIREV with --all-files | |||||
| $ cd sng | |||||
| $ hg rm um | |||||
| $ hg commit -m "deletes um" | |||||
| $ hg grep -r "0:2" "unmod" --all-files | |||||
| um:0:unmod | |||||
| $ cd .. | |||||