Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 40083:4fd0fac48922
localrepo: allow narrowmatch() to accept matcher to intersect with
It's pretty common that we need to intersect a matcher we already have
(usually from the user) with the narrow matcher. Let's make
repo.narrowmatch() take an optional matcher to intersect with.
Differential Revision: https://phab.mercurial-scm.org/D4896
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 28 Sep 2018 12:29:21 -0700 |
parents | 5c3585a58845 |
children | 41fcdfe3bfeb |
comparison
equal
deleted
inserted
replaced
40082:a4d62ff9a86d | 40083:4fd0fac48922 |
---|---|
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 # TODO(martinvonz): make this property-like instead? | 1203 def narrowmatch(self, match=None): |
1204 def narrowmatch(self): | 1204 """matcher corresponding the the repo's narrowspec |
1205 | |
1206 If `match` is given, then that will be intersected with the narrow | |
1207 matcher. | |
1208 """ | |
1209 if match: | |
1210 return matchmod.intersectmatchers(match, self._narrowmatch) | |
1205 return self._narrowmatch | 1211 return self._narrowmatch |
1206 | 1212 |
1207 def setnarrowpats(self, newincludes, newexcludes): | 1213 def setnarrowpats(self, newincludes, newexcludes): |
1208 narrowspec.save(self, newincludes, newexcludes) | 1214 narrowspec.save(self, newincludes, newexcludes) |
1209 self.invalidate(clearfilecache=True) | 1215 self.invalidate(clearfilecache=True) |