Mercurial > hg
comparison mercurial/match.py @ 32325:763d72925691
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).
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 17 May 2017 22:33:15 -0700 |
parents | 77dac8fd30ee |
children | 24245b54aa8a |
comparison
equal
deleted
inserted
replaced
32324:77dac8fd30ee | 32325:763d72925691 |
---|---|
383 self._always = matcher._always | 383 self._always = matcher._always |
384 | 384 |
385 self._files = [f[len(path) + 1:] for f in matcher._files | 385 self._files = [f[len(path) + 1:] for f in matcher._files |
386 if f.startswith(path + "/")] | 386 if f.startswith(path + "/")] |
387 | 387 |
388 # If the parent repo had a path to this subrepo and no patterns are | 388 # If the parent repo had a path to this subrepo and the matcher is |
389 # specified, this submatcher always matches. | 389 # a prefix matcher, this submatcher always matches. |
390 if not self._always and not matcher._anypats: | 390 if matcher.prefix(): |
391 self._always = any(f == path for f in matcher._files) | 391 self._always = any(f == path for f in matcher._files) |
392 | 392 |
393 self._anypats = matcher._anypats | 393 self._anypats = matcher._anypats |
394 # Some information is lost in the superclass's constructor, so we | 394 # Some information is lost in the superclass's constructor, so we |
395 # can not accurately create the matching function for the subdirectory | 395 # can not accurately create the matching function for the subdirectory |