Mercurial > public > mercurial-scm > hg
diff hgext/sparse.py @ 49355:0540c1628fd4
sparse: use None as the sparse matcher value when disabled
This create a clear signal for when the feature is unused. We could also create
an `alwaysmatcher`, but using None is more explicit, so I went for it.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 11 Jun 2022 00:56:50 +0200 |
parents | 216f273b6b30 |
children | a87443d4aec0 |
line wrap: on
line diff
--- a/hgext/sparse.py Wed Jun 08 09:31:01 2022 +0200 +++ b/hgext/sparse.py Sat Jun 11 00:56:50 2022 +0200 @@ -216,9 +216,11 @@ def walk(orig, self, match, subrepos, unknown, ignored, full=True): # hack to not exclude explicitly-specified paths so that they can # be warned later on e.g. dirstate.add() - em = matchmod.exact(match.files()) - sm = matchmod.unionmatcher([self._sparsematcher, em]) - match = matchmod.intersectmatchers(match, sm) + sparse_matcher = self._sparsematcher + if sparse_matcher is not None: + em = matchmod.exact(match.files()) + sm = matchmod.unionmatcher([self._sparsematcher, em]) + match = matchmod.intersectmatchers(match, sm) return orig(self, match, subrepos, unknown, ignored, full) extensions.wrapfunction(dirstate.dirstate, b'walk', walk) @@ -226,7 +228,7 @@ # dirstate.rebuild should not add non-matching files def _rebuild(orig, self, parent, allfiles, changedfiles=None): matcher = self._sparsematcher - if not matcher.always(): + if matcher is not None and not matcher.always(): allfiles = [f for f in allfiles if matcher(f)] if changedfiles: changedfiles = [f for f in changedfiles if matcher(f)] @@ -255,7 +257,7 @@ def _wrapper(orig, self, *args, **kwargs): sparsematch = self._sparsematcher - if not sparsematch.always(): + if sparsematch is not None and not sparsematch.always(): for f in args: if f is not None and not sparsematch(f) and f not in self: raise error.Abort(