sparse: provide sensible __repr__ strings for the custom matchers.

Summary: These matchers provide better values than the default now provided by mercurial.match.basematcher.

Reviewed By: quark-zju

Differential Revision: D7635868

fbshipit-source-id: c826390b3a5e3a2da897eeb54be22850e14403f6
This commit is contained in:
Martijn Pieters 2018-04-16 12:30:35 -07:00 committed by Facebook Github Bot
parent 914d474bbf
commit b31ce422e2

View File

@ -1902,6 +1902,10 @@ class forceincludematcher(matchmod.basematcher):
def __call__(self, value): def __call__(self, value):
return value in self._includes or self._matcher(value) return value in self._includes or self._matcher(value)
def __repr__(self):
return '<forceincludematcher matcher=%r includes=%r>' % (
self._matcher, self._includes)
def visitdir(self, dir): def visitdir(self, dir):
if any(True for path in self._includes if path.startswith(dir)): if any(True for path in self._includes if path.startswith(dir)):
return True return True
@ -1929,6 +1933,9 @@ class negatematcher(matchmod.basematcher):
def __call__(self, value): def __call__(self, value):
return not self._matcher(value) return not self._matcher(value)
def __repr__(self):
return '<negatematcher matcher=%r>' % self._matcher
def hash(self): def hash(self):
sha1 = hashlib.sha1() sha1 = hashlib.sha1()
sha1.update('negate') sha1.update('negate')