# HG changeset patch # User Martin von Zweigbergk # Date 2018-10-01 21:31:15 # Node ID 1d09ba0d2ed3d19f1ca1b116591cc413eb87ac65 # Parent 41fcdfe3bfeb8c9d77b86b3e19f8fc777952d338 narrow: move remaining narrow-limited dirstate walks to core In most places we now filter at a higher level (the context object), but there are few places that relied on the dirstate walk to be filtered by the narrowspec. The important cases are those used by `hg add` and `hg addremove`. This patch updates them to pass in a matcher instead of relying on the dirstate to do the filtering. The dirstate filtering is also dropped in narrowdirstate.py. Not always filtering in the dirstate should be useful for a future `hg status --include-outside-narrow` option. These places now end up doing an unrestricted dirstate walk after this patch: * debugfileset * perfwalk * sparse (but restricted to sparse config) * largefiles I'll let anyone who cares about these cases adapt them to work with narrow if necessary. Differential Revision: https://phab.mercurial-scm.org/D4901 diff --git a/hgext/narrow/TODO.rst b/hgext/narrow/TODO.rst --- a/hgext/narrow/TODO.rst +++ b/hgext/narrow/TODO.rst @@ -14,3 +14,11 @@ server-specified narrowspec format. narrowrepo.setnarrowpats() or narrowspec.save() need to make sure they're holding the wlock. + +The follinwg places do an unrestricted dirstate walk (including files outside the +narrowspec). Some of them should perhaps not do that. + + * debugfileset + * perfwalk + * sparse (but restricted to sparse config) + * largefiles diff --git a/hgext/narrow/narrowdirstate.py b/hgext/narrow/narrowdirstate.py --- a/hgext/narrow/narrowdirstate.py +++ b/hgext/narrow/narrowdirstate.py @@ -26,13 +26,6 @@ def wrapdirstate(repo, dirstate): return _wrapper class narrowdirstate(dirstate.__class__): - def walk(self, match, subrepos, unknown, ignored, full=True, - narrowonly=True): - if narrowonly: - match = repo.narrowmatch(match, includeexact=True) - return super(narrowdirstate, self).walk(match, subrepos, unknown, - ignored, full) - # Prevent adding/editing/copying/deleting files that are outside the # sparse checkout @_editfunc diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2044,6 +2044,7 @@ def add(ui, repo, match, prefix, explici if abort or warn: cca = scmutil.casecollisionauditor(ui, abort, repo.dirstate) + match = repo.narrowmatch(match, includeexact=True) badmatch = matchmod.badmatch(match, badfn) dirstate = repo.dirstate # We don't want to just call wctx.walk here, since it would return a lot of diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -1098,6 +1098,7 @@ def _interestingfiles(repo, matcher): ctx = repo[None] dirstate = repo.dirstate + matcher = repo.narrowmatch(matcher, includeexact=True) walkresults = dirstate.walk(matcher, subrepos=sorted(ctx.substate), unknown=True, ignored=False, full=False) for abs, st in walkresults.iteritems():