Mercurial > public > mercurial-scm > hg
diff hgext/sparse.py @ 49360:bd3519dc6741
sparse: directly inline the `set_tracked` and `copy` wrapping
core is already aware of sparse, so lets move the handful of line of code that
deal with this for the sake of simplicity and explicitness.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 10 Jun 2022 23:19:04 +0200 |
parents | 05da1f1612db |
children | b1147450c55c |
line wrap: on
line diff
--- a/hgext/sparse.py Sat Jun 11 00:00:29 2022 +0200 +++ b/hgext/sparse.py Fri Jun 10 23:19:04 2022 +0200 @@ -77,7 +77,6 @@ from mercurial import ( cmdutil, commands, - dirstate, error, extensions, logcmdutil, @@ -104,7 +103,6 @@ _setupclone(ui) _setuplog(ui) _setupadd(ui) - _setupdirstate(ui) def replacefilecache(cls, propname, replacement): @@ -207,40 +205,6 @@ extensions.wrapcommand(commands.table, b'add', _add) -def _setupdirstate(ui): - """Modify the dirstate to prevent stat'ing excluded files, - and to prevent modifications to files outside the checkout. - """ - - # Prevent adding files that are outside the sparse checkout - editfuncs = [ - b'set_tracked', - b'copy', - ] - hint = _( - b'include file with `hg debugsparse --include <pattern>` or use ' - + b'`hg add -s <file>` to include file directory while adding' - ) - for func in editfuncs: - - def _wrapper(orig, self, *args, **kwargs): - sparsematch = self._sparsematcher - 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( - _( - b"cannot add '%s' - it is outside " - b"the sparse checkout" - ) - % f, - hint=hint, - ) - return orig(self, *args, **kwargs) - - extensions.wrapfunction(dirstate.dirstate, func, _wrapper) - - @command( b'debugsparse', [