Mercurial > hg
changeset 44850:8d552701806d
grep: stop computing information for --diff when unnecessary
This is one reason why `hg grep pattern` essentially does `hg cat -r
. 'set:**'` inside. There is no speed improvement in this commit,
because the rest of the code still greps data from filelog instead of
working copy when possible.
Differential Revision: https://phab.mercurial-scm.org/D8544
author | Valentin Gatien-Baron <valentin.gatienbaron@gmail.com> |
---|---|
date | Sun, 17 May 2020 13:10:54 -0400 |
parents | f90957c947f4 |
children | 708ad5cf5e5a |
files | mercurial/commands.py |
diffstat | 1 files changed, 14 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sun May 17 12:52:43 2020 -0400 +++ b/mercurial/commands.py Sun May 17 13:10:54 2020 -0400 @@ -3594,9 +3594,10 @@ def prep(ctx, fns): rev = ctx.rev() pctx = ctx.p1() - parent = pctx.rev() matches.setdefault(rev, {}) - matches.setdefault(parent, {}) + if diff: + parent = pctx.rev() + matches.setdefault(parent, {}) files = revfiles.setdefault(rev, []) for fn in fns: flog = getfile(fn) @@ -3620,14 +3621,17 @@ content = get_file_content(fn, flog, fnode, ctx, rev) grepbody(fn, rev, content) - pfn = copy or fn - if pfn not in matches[parent]: - try: - pfnode = pctx.filenode(pfn) - pcontent = get_file_content(pfn, flog, pfnode, pctx, parent) - grepbody(pfn, parent, pcontent) - except error.LookupError: - pass + if diff: + pfn = copy or fn + if pfn not in matches[parent]: + try: + pfnode = pctx.filenode(pfn) + pcontent = get_file_content( + pfn, flog, pfnode, pctx, parent + ) + grepbody(pfn, parent, pcontent) + except error.LookupError: + pass ui.pager(b'grep') fm = ui.formatter(b'grep', opts)