Mercurial > hg
comparison mercurial/dirstate.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 | 97dcd6906e6f |
children | a87443d4aec0 |
comparison
equal
deleted
inserted
replaced
49354:216f273b6b30 | 49355:0540c1628fd4 |
---|---|
25 node, | 25 node, |
26 pathutil, | 26 pathutil, |
27 policy, | 27 policy, |
28 pycompat, | 28 pycompat, |
29 scmutil, | 29 scmutil, |
30 sparse, | |
31 util, | 30 util, |
32 ) | 31 ) |
33 | 32 |
34 from .dirstateutils import ( | 33 from .dirstateutils import ( |
35 timestamp, | 34 timestamp, |
111 self._use_tracked_hint = use_tracked_hint | 110 self._use_tracked_hint = use_tracked_hint |
112 self._nodeconstants = nodeconstants | 111 self._nodeconstants = nodeconstants |
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) |
119 self._rootdir = pathutil.normasprefix(root) | 119 self._rootdir = pathutil.normasprefix(root) |
120 # True is any internal state may be different | 120 # True is any internal state may be different |
182 """The matcher for the sparse checkout. | 182 """The matcher for the sparse checkout. |
183 | 183 |
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 """ | 187 |
188 When sparse if disabled, return None. | |
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.) |
191 return self._sparsematchfn() | 195 return self._sparsematchfn() |
192 | 196 |
1257 elif self._checkcase: | 1261 elif self._checkcase: |
1258 # Case-insensitive filesystems are not handled yet | 1262 # Case-insensitive filesystems are not handled yet |
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 |
1266 use_rust = False | 1270 use_rust = False |
1267 | 1271 |