largefiles: track if a matcher was tampered with
This is used to make sure rust fast path is not taken for the
modified matchers.
--- a/hgext/largefiles/overrides.py Wed Apr 17 12:28:48 2024 +0200
+++ b/hgext/largefiles/overrides.py Tue Apr 09 11:00:52 2024 +0100
@@ -71,6 +71,7 @@
"""create a matcher that matches only the largefiles in the original
matcher"""
m = copy.copy(match)
+ m._was_tampered_with = True
lfile = lambda f: lfutil.standin(f) in manifest
m._files = [lf for lf in m._files if lfile(lf)]
m._fileset = set(m._files)
@@ -86,6 +87,7 @@
excluded.update(exclude)
m = copy.copy(match)
+ m._was_tampered_with = True
notlfile = lambda f: not (
lfutil.isstandin(f) or lfutil.standin(f) in manifest or f in excluded
)
@@ -442,6 +444,8 @@
pats.update(fixpats(f, tostandin) for f in p)
+ m._was_tampered_with = True
+
for i in range(0, len(m._files)):
# Don't add '.hglf' to m.files, since that is already covered by '.'
if m._files[i] == b'.':
@@ -849,6 +853,7 @@
newpats.append(pat)
match = orig(ctx, newpats, opts, globbed, default, badfn=badfn)
m = copy.copy(match)
+ m._was_tampered_with = True
lfile = lambda f: lfutil.standin(f) in manifest
m._files = [lfutil.standin(f) for f in m._files if lfile(f)]
m._fileset = set(m._files)
@@ -967,6 +972,7 @@
opts = {}
match = orig(mctx, pats, opts, globbed, default, badfn=badfn)
m = copy.copy(match)
+ m._was_tampered_with = True
# revert supports recursing into subrepos, and though largefiles
# currently doesn't work correctly in that case, this match is
@@ -1595,6 +1601,7 @@
# confused state later.
if s.deleted:
m = copy.copy(matcher)
+ m._was_tampered_with = True
# The m._files and m._map attributes are not changed to the deleted list
# because that affects the m.exact() test, which in turn governs whether
@@ -1721,6 +1728,7 @@
err = 1
notbad = set()
m = scmutil.match(ctx, (file1,) + pats, pycompat.byteskwargs(opts))
+ m._was_tampered_with = True
origmatchfn = m.matchfn
def lfmatchfn(f):
--- a/mercurial/match.py Wed Apr 17 12:28:48 2024 +0200
+++ b/mercurial/match.py Tue Apr 09 11:00:52 2024 +0100
@@ -395,9 +395,15 @@
class basematcher:
def __init__(self, badfn=None):
+ self._was_tampered_with = False
if badfn is not None:
self.bad = badfn
+ def was_tampered_with(self):
+ # [_was_tampered_with] is used to track if when extensions changed the matcher
+ # behavior (crazy stuff!), so we disable the rust fast path.
+ return self._was_tampered_with
+
def __call__(self, fn):
return self.matchfn(fn)