diff -r aa41f1b01f31 -r 41fcdfe3bfeb mercurial/localrepo.py --- 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