# HG changeset patch # User Martin von Zweigbergk # Date 1428511089 25200 # Node ID b3d78d82d84ca79524d6b17d75ad217aef5e6655 # Parent ff7badaf315838e279e52e0b8f6d87fb2f183c09 manifestdict: extract condition for _intersectfiles() and use for walk() The condition on which manifestdict.matches() and manifestdict.walk() take the fast path of iterating over files instead of the manifest, is slightly different. Specifically, walk() does not take the fast path for exact matchers and it does not avoid taking the fast path when there are more than 100 files. Let's extract the condition so we don't have to maintain it in two places and so walk() can gain these two missing pieces of the condition (although there seems to be no current caller of walk() with an exact matcher). diff -r ff7badaf3158 -r b3d78d82d84c mercurial/manifest.py --- a/mercurial/manifest.py Tue Apr 07 22:40:25 2015 -0700 +++ b/mercurial/manifest.py Wed Apr 08 09:38:09 2015 -0700 @@ -214,6 +214,13 @@ def hasdir(self, dir): return dir in self._dirs + def _filesfastpath(self, match): + '''Checks whether we can correctly and quickly iterate over matcher + files instead of over manifest files.''' + files = match.files() + return (len(files) < 100 and (match.isexact() or + (not match.anypats() and util.all(fn in self for fn in files)))) + def walk(self, match): '''Generates matching file names. @@ -230,7 +237,7 @@ fset = set(match.files()) # avoid the entire walk if we're only looking for specific files - if not match.anypats() and util.all(fn in self for fn in fset): + if self._filesfastpath(match): for fn in sorted(fset): yield fn return @@ -255,9 +262,7 @@ if match.always(): return self.copy() - files = match.files() - if (len(files) < 100 and (match.isexact() or - (not match.anypats() and util.all(fn in self for fn in files)))): + if self._filesfastpath(match): m = manifestdict() lm = self._lm for fn in match.files():