Mercurial > hg
comparison mercurial/match.py @ 32406:952017471f93
match: implement __repr__() and update users (API)
fsmonitor and debugignore currently access matcher fields that I would
consider implementation details, namely patternspat, includepat, and
excludepat. Let' instead implement __repr__() and have the few users
use that instead.
Marked (API) because the fields can now be None.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 22 May 2017 11:08:18 -0700 |
parents | 284b18303f61 |
children | 9695aca1a3a0 |
comparison
equal
deleted
inserted
replaced
32405:bdc4861ffe59 | 32406:952017471f93 |
---|---|
212 self._cwd = cwd | 212 self._cwd = cwd |
213 self._files = [] # exact files and roots of patterns | 213 self._files = [] # exact files and roots of patterns |
214 self._anypats = bool(include or exclude) | 214 self._anypats = bool(include or exclude) |
215 self._always = False | 215 self._always = False |
216 self._pathrestricted = bool(include or exclude or patterns) | 216 self._pathrestricted = bool(include or exclude or patterns) |
217 self.patternspat = None | |
218 self.includepat = None | |
219 self.excludepat = None | |
217 | 220 |
218 # roots are directories which are recursively included/excluded. | 221 # roots are directories which are recursively included/excluded. |
219 self._includeroots = set() | 222 self._includeroots = set() |
220 self._excluderoots = set() | 223 self._excluderoots = set() |
221 # dirs are directories which are non-recursively included. | 224 # dirs are directories which are non-recursively included. |
372 def isexact(self): | 375 def isexact(self): |
373 return self.matchfn == self.exact | 376 return self.matchfn == self.exact |
374 | 377 |
375 def prefix(self): | 378 def prefix(self): |
376 return not self.always() and not self.isexact() and not self.anypats() | 379 return not self.always() and not self.isexact() and not self.anypats() |
380 | |
381 def __repr__(self): | |
382 return ('<matcher files=%r, patterns=%r, includes=%r, excludes=%r>' % | |
383 (self._files, self.patternspat, self.includepat, | |
384 self.excludepat)) | |
377 | 385 |
378 class subdirmatcher(matcher): | 386 class subdirmatcher(matcher): |
379 """Adapt a matcher to work on a subdirectory only. | 387 """Adapt a matcher to work on a subdirectory only. |
380 | 388 |
381 The paths are remapped to remove/insert the path as needed: | 389 The paths are remapped to remove/insert the path as needed: |