[PATCH 4 of 4] match: use match.prefix() in subdirmatcher
Martin von Zweigbergk
martinvonz at google.com
Thu May 18 14:03:46 EDT 2017
# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1495085595 25200
# Wed May 17 22:33:15 2017 -0700
# Node ID 995b116349ea7a11858ce81df36bfdb345a18f0d
# Parent 786822a7d1d8c5c90f393ea2d0fc06cdb0a96a00
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).
diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -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
More information about the Mercurial-devel
mailing list