context: generate filtered manifest efficiently for exact matchers
When the matcher is exact, there's no reason to iterate over the entire
manifest. It's much more efficient to iterate over the list of files instead.
For a repository with approximately 300,000 files, this speeds up
hg log -l10 --patch --follow for a frequently modified file from 16.5 seconds
to 10.5 seconds.
--- a/mercurial/context.py Sat Jul 12 17:57:25 2014 -0700
+++ b/mercurial/context.py Sat Jul 12 17:59:03 2014 -0700
@@ -71,9 +71,13 @@
object oriented way for other contexts to customize the manifest
generation.
"""
+ if match.always():
+ return self.manifest().copy()
+
+ if match.matchfn == match.exact:
+ return self.manifest().intersectfiles(match.files())
+
mf = self.manifest().copy()
- if match.always():
- return mf
for fn in mf.keys():
if not match(fn):
del mf[fn]