context: generate filtered manifest efficiently for exact matchers
authorSiddharth Agarwal <sid0@fb.com>
Sat, 12 Jul 2014 17:59:03 -0700
changeset 21880 e6754f5e4cf7
parent 21879 090dcaaf3fff
child 21881 6f332778f904
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.
mercurial/context.py
--- 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]