match: use match.prefix() in subdirmatcher
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 17 May 2017 22:33:15 -0700
changeset 32325 763d72925691
parent 32324 77dac8fd30ee
child 32327 3546a771e376
match: use match.prefix() in subdirmatcher It seems like the subdirmatcher should be checking if the matcher it's based on is matching prefixes. It was effectively doing that already because "prefix() == not always() and not anypats() and not isexact()", subdirmatcher was checking the first two parts of that condition and I don't think it will ever be given an "exact" matcher with it's directory name (because exact matchers are for matching files, not directories). Still, let's switch to using prefix() for clarity (and because I'm trying to remove code that reaches for matchers internals).
mercurial/match.py
--- a/mercurial/match.py	Fri May 12 16:31:21 2017 -0700
+++ b/mercurial/match.py	Wed May 17 22:33:15 2017 -0700
@@ -385,9 +385,9 @@
         self._files = [f[len(path) + 1:] for f in matcher._files
                        if f.startswith(path + "/")]
 
-        # If the parent repo had a path to this subrepo and no patterns are
-        # specified, this submatcher always matches.
-        if not self._always and not matcher._anypats:
+        # If the parent repo had a path to this subrepo and the matcher is
+        # a prefix matcher, this submatcher always matches.
+        if matcher.prefix():
             self._always = any(f == path for f in matcher._files)
 
         self._anypats = matcher._anypats