From patchwork Mon Jan 13 14:18:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7820: grep: speed up `hg grep --all-files some/path` by using ctx.matches(match) From: phabricator X-Patchwork-Id: 44266 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 13 Jan 2020 14:18:56 +0000 Closed by commit rHG6cfaebb625d3: grep: speed up `hg grep --all-files some/path` by using ctx.matches(match) (authored by martinvonz). This revision was automatically updated to reflect the committed changes. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7820?vs=19140&id=19160 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7820/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7820 AFFECTED FILES mercurial/cmdutil.py CHANGE DETAILS To: martinvonz, #hg-reviewers, pulkit Cc: mercurial-devel diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2429,12 +2429,16 @@ def fns_generator(): if allfiles: - fiter = iter(ctx) + + def bad(f, msg): + pass + + for f in ctx.matches(matchmod.badmatch(match, bad)): + yield f else: - fiter = ctx.files() - for f in fiter: - if match(f): - yield f + for f in ctx.files(): + if match(f): + yield f fns = fns_generator() prepare(ctx, fns)