Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 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 | 4fd0fac48922 |
children | 9d5ddf55415b |
comparison
equal
deleted
inserted
replaced
40086:aa41f1b01f31 | 40087:41fcdfe3bfeb |
---|---|
1198 if repository.NARROW_REQUIREMENT not in self.requirements: | 1198 if repository.NARROW_REQUIREMENT not in self.requirements: |
1199 return matchmod.always(self.root, '') | 1199 return matchmod.always(self.root, '') |
1200 include, exclude = self.narrowpats | 1200 include, exclude = self.narrowpats |
1201 return narrowspec.match(self.root, include=include, exclude=exclude) | 1201 return narrowspec.match(self.root, include=include, exclude=exclude) |
1202 | 1202 |
1203 def narrowmatch(self, match=None): | 1203 def narrowmatch(self, match=None, includeexact=False): |
1204 """matcher corresponding the the repo's narrowspec | 1204 """matcher corresponding the the repo's narrowspec |
1205 | 1205 |
1206 If `match` is given, then that will be intersected with the narrow | 1206 If `match` is given, then that will be intersected with the narrow |
1207 matcher. | 1207 matcher. |
1208 | |
1209 If `includeexact` is True, then any exact matches from `match` will | |
1210 be included even if they're outside the narrowspec. | |
1208 """ | 1211 """ |
1209 if match: | 1212 if match: |
1213 if includeexact and not self._narrowmatch.always(): | |
1214 # do not exclude explicitly-specified paths so that they can | |
1215 # be warned later on | |
1216 em = matchmod.exact(match._root, match._cwd, match.files()) | |
1217 nm = matchmod.unionmatcher([self._narrowmatch, em]) | |
1218 return matchmod.intersectmatchers(match, nm) | |
1210 return matchmod.intersectmatchers(match, self._narrowmatch) | 1219 return matchmod.intersectmatchers(match, self._narrowmatch) |
1211 return self._narrowmatch | 1220 return self._narrowmatch |
1212 | 1221 |
1213 def setnarrowpats(self, newincludes, newexcludes): | 1222 def setnarrowpats(self, newincludes, newexcludes): |
1214 narrowspec.save(self, newincludes, newexcludes) | 1223 narrowspec.save(self, newincludes, newexcludes) |