diff mercurial/localrepo.py @ 40086: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
line wrap: on
line diff
--- 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