Mercurial > hg-stable
changeset 40087:41fcdfe3bfeb
narrow: allow repo.narrowmatch(match) to include exact matches from "match"
Differential Revision: https://phab.mercurial-scm.org/D4900
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 01 Oct 2018 10:11:00 -0700 |
parents | aa41f1b01f31 |
children | 1d09ba0d2ed3 |
files | hgext/narrow/narrowdirstate.py mercurial/localrepo.py |
diffstat | 2 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/narrow/narrowdirstate.py Fri Sep 28 22:35:05 2018 -0700 +++ b/hgext/narrow/narrowdirstate.py Mon Oct 01 10:11:00 2018 -0700 @@ -10,7 +10,6 @@ from mercurial.i18n import _ from mercurial import ( error, - match as matchmod, ) def wrapdirstate(repo, dirstate): @@ -30,11 +29,7 @@ def walk(self, match, subrepos, unknown, ignored, full=True, narrowonly=True): if narrowonly: - # hack to not exclude explicitly-specified paths so that they - # can be warned later on e.g. dirstate.add() - em = matchmod.exact(match._root, match._cwd, match.files()) - nm = matchmod.unionmatcher([repo.narrowmatch(), em]) - match = matchmod.intersectmatchers(match, nm) + match = repo.narrowmatch(match, includeexact=True) return super(narrowdirstate, self).walk(match, subrepos, unknown, ignored, full)
--- a/mercurial/localrepo.py Fri Sep 28 22:35:05 2018 -0700 +++ b/mercurial/localrepo.py Mon Oct 01 10:11:00 2018 -0700 @@ -1200,13 +1200,22 @@ include, exclude = self.narrowpats return narrowspec.match(self.root, include=include, exclude=exclude) - def narrowmatch(self, match=None): + def narrowmatch(self, match=None, includeexact=False): """matcher corresponding the the repo's narrowspec If `match` is given, then that will be intersected with the narrow matcher. + + If `includeexact` is True, then any exact matches from `match` will + be included even if they're outside the narrowspec. """ if match: + if includeexact and not self._narrowmatch.always(): + # do not exclude explicitly-specified paths so that they can + # be warned later on + em = matchmod.exact(match._root, match._cwd, match.files()) + nm = matchmod.unionmatcher([self._narrowmatch, em]) + return matchmod.intersectmatchers(match, nm) return matchmod.intersectmatchers(match, self._narrowmatch) return self._narrowmatch