Show More
@@ -142,9 +142,12 b' def match(root, cwd, patterns, include=N' | |||
|
142 | 142 | kindpats.append((kind, pats, source)) |
|
143 | 143 | return kindpats |
|
144 | 144 | |
|
145 | m = matcher(root, cwd, normalize, patterns, include=None, | |
|
146 | default=default, exact=exact, auditor=auditor, ctx=ctx, | |
|
147 | listsubrepos=listsubrepos, warn=warn, badfn=badfn) | |
|
145 | if exact: | |
|
146 | m = exactmatcher(root, cwd, patterns, badfn) | |
|
147 | else: | |
|
148 | m = matcher(root, cwd, normalize, patterns, include=None, | |
|
149 | default=default, exact=exact, auditor=auditor, ctx=ctx, | |
|
150 | listsubrepos=listsubrepos, warn=warn, badfn=badfn) | |
|
148 | 151 | if include: |
|
149 | 152 | im = matcher(root, cwd, normalize, [], include=include, default=default, |
|
150 | 153 | exact=False, auditor=auditor, ctx=ctx, |
@@ -158,7 +161,7 b' def match(root, cwd, patterns, include=N' | |||
|
158 | 161 | return m |
|
159 | 162 | |
|
160 | 163 | def exact(root, cwd, files, badfn=None): |
|
161 |
return match(root, cwd, files, |
|
|
164 | return exactmatcher(root, cwd, files, badfn=badfn) | |
|
162 | 165 | |
|
163 | 166 | def always(root, cwd): |
|
164 | 167 | return match(root, cwd, []) |
@@ -406,6 +409,33 b' class matcher(basematcher):' | |||
|
406 | 409 | return ('<matcher files=%r, patterns=%r, includes=%r>' % |
|
407 | 410 | (self._files, self.patternspat, self.includepat)) |
|
408 | 411 | |
|
412 | class exactmatcher(basematcher): | |
|
413 | '''Matches the input files exactly. They are interpreted as paths, not | |
|
414 | patterns (so no kind-prefixes). | |
|
415 | ''' | |
|
416 | ||
|
417 | def __init__(self, root, cwd, files, badfn=None): | |
|
418 | super(exactmatcher, self).__init__(root, cwd, badfn) | |
|
419 | ||
|
420 | if isinstance(files, list): | |
|
421 | self._files = files | |
|
422 | else: | |
|
423 | self._files = list(files) | |
|
424 | self.matchfn = self.exact | |
|
425 | ||
|
426 | @propertycache | |
|
427 | def _dirs(self): | |
|
428 | return set(util.dirs(self._fileset)) | {'.'} | |
|
429 | ||
|
430 | def visitdir(self, dir): | |
|
431 | return dir in self._dirs | |
|
432 | ||
|
433 | def isexact(self): | |
|
434 | return True | |
|
435 | ||
|
436 | def __repr__(self): | |
|
437 | return ('<exactmatcher files=%r>' % self._files) | |
|
438 | ||
|
409 | 439 | class differencematcher(basematcher): |
|
410 | 440 | '''Composes two matchers by matching if the first matches and the second |
|
411 | 441 | does not. Well, almost... If the user provides a pattern like "-X foo foo", |
General Comments 0
You need to be logged in to leave comments.
Login now