Show More
@@ -142,6 +142,9 def match(root, cwd, patterns, include=N | |||||
142 | kindpats.append((kind, pats, source)) |
|
142 | kindpats.append((kind, pats, source)) | |
143 | return kindpats |
|
143 | return kindpats | |
144 |
|
144 | |||
|
145 | if exact: | |||
|
146 | m = exactmatcher(root, cwd, patterns, badfn) | |||
|
147 | else: | |||
145 | m = matcher(root, cwd, normalize, patterns, include=None, |
|
148 | m = matcher(root, cwd, normalize, patterns, include=None, | |
146 | default=default, exact=exact, auditor=auditor, ctx=ctx, |
|
149 | default=default, exact=exact, auditor=auditor, ctx=ctx, | |
147 | listsubrepos=listsubrepos, warn=warn, badfn=badfn) |
|
150 | listsubrepos=listsubrepos, warn=warn, badfn=badfn) | |
@@ -158,7 +161,7 def match(root, cwd, patterns, include=N | |||||
158 | return m |
|
161 | return m | |
159 |
|
162 | |||
160 | def exact(root, cwd, files, badfn=None): |
|
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 | def always(root, cwd): |
|
166 | def always(root, cwd): | |
164 | return match(root, cwd, []) |
|
167 | return match(root, cwd, []) | |
@@ -406,6 +409,33 class matcher(basematcher): | |||||
406 | return ('<matcher files=%r, patterns=%r, includes=%r>' % |
|
409 | return ('<matcher files=%r, patterns=%r, includes=%r>' % | |
407 | (self._files, self.patternspat, self.includepat)) |
|
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 | class differencematcher(basematcher): |
|
439 | class differencematcher(basematcher): | |
410 | '''Composes two matchers by matching if the first matches and the second |
|
440 | '''Composes two matchers by matching if the first matches and the second | |
411 | does not. Well, almost... If the user provides a pattern like "-X foo foo", |
|
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