This instance will be upgraded to Heptapod 0.26.0rc1 on 2021-10-25 at 14:00 UTC+2 (a few minutes of down time)

Commit 13e939ff authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

grep: extract public function to register file to be skipped

The main grep loop will be extracted to a searcher method, but this skipping
condition depends on the result of display() function.
parent 87c35b5a14eb
......@@ -3549,9 +3549,7 @@ def grep(ui, repo, pattern, *pats, **opts):
r = display(fm, fn, ctx, pstates, states)
found = found or r
if r and not diff and not all_files:
if copy:
searcher.skipfile(fn, rev)
del revfiles[rev]
# We will keep the matches dict for the duration of the window
# clear the matches dict once the window is over
......@@ -107,6 +107,14 @@ class grepsearcher(object):
self._skip = set()
self._revfiles = {}
def skipfile(self, fn, rev):
"""Exclude the given file (and the copy at the specified revision)
from future search"""
copy = self._copies.get(rev, {}).get(fn)
if copy:
def _grepbody(self, fn, rev, body):
self._matches[rev].setdefault(fn, [])
m = self._matches[rev][fn]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment