Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 44049:6cfaebb625d3
grep: speed up `hg grep --all-files some/path` by using ctx.matches(match)
ctx.matches(match) avoids walking unintersting parts of the tree when
using tree manifests. That can make a very big difference when
grepping in a small subset of the tree (2.0s -> 0.7s in my case, but
can of course be made more extreme by picking a smaller subset of
files).
Differential Revision: https://phab.mercurial-scm.org/D7820
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 09 Jan 2020 15:41:40 -0800 |
parents | 6c8108274dc5 |
children | 19533e4c3450 |
comparison
equal
deleted
inserted
replaced
44047:de5d34ca01bd | 44049:6cfaebb625d3 |
---|---|
2427 ctx = change(rev) | 2427 ctx = change(rev) |
2428 if not fns: | 2428 if not fns: |
2429 | 2429 |
2430 def fns_generator(): | 2430 def fns_generator(): |
2431 if allfiles: | 2431 if allfiles: |
2432 fiter = iter(ctx) | 2432 |
2433 def bad(f, msg): | |
2434 pass | |
2435 | |
2436 for f in ctx.matches(matchmod.badmatch(match, bad)): | |
2437 yield f | |
2433 else: | 2438 else: |
2434 fiter = ctx.files() | 2439 for f in ctx.files(): |
2435 for f in fiter: | 2440 if match(f): |
2436 if match(f): | 2441 yield f |
2437 yield f | |
2438 | 2442 |
2439 fns = fns_generator() | 2443 fns = fns_generator() |
2440 prepare(ctx, fns) | 2444 prepare(ctx, fns) |
2441 for rev in nrevs: | 2445 for rev in nrevs: |
2442 yield change(rev) | 2446 yield change(rev) |