sparse: implement negatematcher.visitdir

Summary:
`negatematcher.visitdir` was using the default implementation - `return True`.

It's correct but not helpful to skip visiting a large directory. Make it return
more efficient results if possible.

Reviewed By: DurhamG

Differential Revision: D10352848

fbshipit-source-id: 05b19342192a54e114d02564058435fb3ac34590
This commit is contained in:
Jun Wu 2018-10-19 15:53:36 -07:00 committed by Facebook Github Bot
parent 84d4d887bc
commit c990d8cd4f

View File

@ -2506,6 +2506,15 @@ class negatematcher(matchmod.basematcher):
def __repr__(self): def __repr__(self):
return "<negatematcher matcher=%r>" % self._matcher return "<negatematcher matcher=%r>" % self._matcher
def visitdir(self, dir):
orig = self._matcher.visitdir(dir)
if orig == "all":
return False
elif orig is False:
return "all"
else:
return True
def hash(self): def hash(self):
sha1 = hashlib.sha1() sha1 = hashlib.sha1()
sha1.update("negate") sha1.update("negate")