Mercurial > hg
comparison mercurial/match.py @ 32554:f44ea253ffe2
match: optimize visitdir() for when no explicit files are listed
In patternmatcher, we used to say that all directories should be
visited if no explicit files were listed, because the case of empty
_files usually implied that no patterns were given (which in turns
meant that everything should match). However, this made e.g. "hg files
-r . rootfilesin:." slower than necessary, because that also ended
up with an empty list in _files. Now that patternmatcher does not
handle includes, the only remaining case where its _files/_fileset
fields will be empty is when it's matching everything. We can
therefore treat the always-case specially and stop treating the empty
_files case specially. This makes the case mentioned above faster on
treemanifest repos.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sat, 20 May 2017 23:49:14 -0700 |
parents | 20c9f3ecc192 |
children | b3083be7dcb9 |
comparison
equal
deleted
inserted
replaced
32553:20c9f3ecc192 | 32554:f44ea253ffe2 |
---|---|
375 @propertycache | 375 @propertycache |
376 def _dirs(self): | 376 def _dirs(self): |
377 return set(util.dirs(self._fileset)) | {'.'} | 377 return set(util.dirs(self._fileset)) | {'.'} |
378 | 378 |
379 def visitdir(self, dir): | 379 def visitdir(self, dir): |
380 if self.always(): | |
381 return 'all' | |
380 if self.prefix() and dir in self._fileset: | 382 if self.prefix() and dir in self._fileset: |
381 return 'all' | 383 return 'all' |
382 return (not self._fileset or | 384 return ('.' in self._fileset or |
383 '.' in self._fileset or | |
384 dir in self._fileset or | 385 dir in self._fileset or |
385 dir in self._dirs or | 386 dir in self._dirs or |
386 any(parentdir in self._fileset | 387 any(parentdir in self._fileset |
387 for parentdir in util.finddirs(dir))) | 388 for parentdir in util.finddirs(dir))) |
388 | 389 |