##// END OF EJS Templates
sparse: use None as the sparse matcher value when disabled...
marmoute -
r50250:0540c162 default
parent child Browse files
Show More
@@ -216,9 +216,11 b' def _setupdirstate(ui):'
216 def walk(orig, self, match, subrepos, unknown, ignored, full=True):
216 def walk(orig, self, match, subrepos, unknown, ignored, full=True):
217 # hack to not exclude explicitly-specified paths so that they can
217 # hack to not exclude explicitly-specified paths so that they can
218 # be warned later on e.g. dirstate.add()
218 # be warned later on e.g. dirstate.add()
219 em = matchmod.exact(match.files())
219 sparse_matcher = self._sparsematcher
220 sm = matchmod.unionmatcher([self._sparsematcher, em])
220 if sparse_matcher is not None:
221 match = matchmod.intersectmatchers(match, sm)
221 em = matchmod.exact(match.files())
222 sm = matchmod.unionmatcher([self._sparsematcher, em])
223 match = matchmod.intersectmatchers(match, sm)
222 return orig(self, match, subrepos, unknown, ignored, full)
224 return orig(self, match, subrepos, unknown, ignored, full)
223
225
224 extensions.wrapfunction(dirstate.dirstate, b'walk', walk)
226 extensions.wrapfunction(dirstate.dirstate, b'walk', walk)
@@ -226,7 +228,7 b' def _setupdirstate(ui):'
226 # dirstate.rebuild should not add non-matching files
228 # dirstate.rebuild should not add non-matching files
227 def _rebuild(orig, self, parent, allfiles, changedfiles=None):
229 def _rebuild(orig, self, parent, allfiles, changedfiles=None):
228 matcher = self._sparsematcher
230 matcher = self._sparsematcher
229 if not matcher.always():
231 if matcher is not None and not matcher.always():
230 allfiles = [f for f in allfiles if matcher(f)]
232 allfiles = [f for f in allfiles if matcher(f)]
231 if changedfiles:
233 if changedfiles:
232 changedfiles = [f for f in changedfiles if matcher(f)]
234 changedfiles = [f for f in changedfiles if matcher(f)]
@@ -255,7 +257,7 b' def _setupdirstate(ui):'
255
257
256 def _wrapper(orig, self, *args, **kwargs):
258 def _wrapper(orig, self, *args, **kwargs):
257 sparsematch = self._sparsematcher
259 sparsematch = self._sparsematcher
258 if not sparsematch.always():
260 if sparsematch is not None and not sparsematch.always():
259 for f in args:
261 for f in args:
260 if f is not None and not sparsematch(f) and f not in self:
262 if f is not None and not sparsematch(f) and f not in self:
261 raise error.Abort(
263 raise error.Abort(
@@ -27,7 +27,6 b' from . import ('
27 policy,
27 policy,
28 pycompat,
28 pycompat,
29 scmutil,
29 scmutil,
30 sparse,
31 util,
30 util,
32 )
31 )
33
32
@@ -113,6 +112,7 b' class dirstate:'
113 self._opener = opener
112 self._opener = opener
114 self._validate = validate
113 self._validate = validate
115 self._root = root
114 self._root = root
115 # Either build a sparse-matcher or None if sparse is disabled
116 self._sparsematchfn = sparsematchfn
116 self._sparsematchfn = sparsematchfn
117 # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is
117 # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is
118 # UNC path pointing to root share (issue4557)
118 # UNC path pointing to root share (issue4557)
@@ -184,7 +184,11 b' class dirstate:'
184 The working directory may not include every file from a manifest. The
184 The working directory may not include every file from a manifest. The
185 matcher obtained by this property will match a path if it is to be
185 matcher obtained by this property will match a path if it is to be
186 included in the working directory.
186 included in the working directory.
187
188 When sparse if disabled, return None.
187 """
189 """
190 if self._sparsematchfn is None:
191 return None
188 # TODO there is potential to cache this property. For now, the matcher
192 # TODO there is potential to cache this property. For now, the matcher
189 # is resolved on every access. (But the called function does use a
193 # is resolved on every access. (But the called function does use a
190 # cache to keep the lookup fast.)
194 # cache to keep the lookup fast.)
@@ -1259,7 +1263,7 b' class dirstate:'
1259 use_rust = False
1263 use_rust = False
1260 elif subrepos:
1264 elif subrepos:
1261 use_rust = False
1265 use_rust = False
1262 elif sparse.enabled:
1266 elif self._sparsematchfn is not None:
1263 use_rust = False
1267 use_rust = False
1264 elif not isinstance(match, allowed_matchers):
1268 elif not isinstance(match, allowed_matchers):
1265 # Some matchers have yet to be implemented
1269 # Some matchers have yet to be implemented
@@ -1747,7 +1747,9 b' class localrepository:'
1747
1747
1748 def _makedirstate(self):
1748 def _makedirstate(self):
1749 """Extension point for wrapping the dirstate per-repo."""
1749 """Extension point for wrapping the dirstate per-repo."""
1750 sparsematchfn = lambda: sparse.matcher(self)
1750 sparsematchfn = None
1751 if sparse.use_sparse(self):
1752 sparsematchfn = lambda: sparse.matcher(self)
1751 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
1753 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
1752 th = requirementsmod.DIRSTATE_TRACKED_HINT_V1
1754 th = requirementsmod.DIRSTATE_TRACKED_HINT_V1
1753 use_dirstate_v2 = v2_req in self.requirements
1755 use_dirstate_v2 = v2_req in self.requirements
General Comments 0
You need to be logged in to leave comments. Login now