context: extend efficient manifest filtering to when all paths are files
On a repository with over 250,000 files and 700,000 commits, this improves
cases like
hg status --rev <rev> -- <file> # rev is not .
from 2.1 seconds to 1.4 seconds.
There is further scope for improvement here: for a single file or a small set
of files, it is probably more efficient to use filelog linkrevs when possible.
However there will always be cases where that will fail (multiple commits
pointing to the same file revision, removed files...), so this is independently
useful.
--- a/mercurial/context.py Sat Jul 12 00:37:08 2014 -0700
+++ b/mercurial/context.py Wed Jul 16 14:53:03 2014 -0700
@@ -74,8 +74,10 @@
if match.always():
return self.manifest().copy()
- if match.matchfn == match.exact:
- return self.manifest().intersectfiles(match.files())
+ files = match.files()
+ if (match.matchfn == match.exact or
+ (not match.anypats() and util.all(fn in self for fn in files))):
+ return self.manifest().intersectfiles(files)
mf = self.manifest().copy()
for fn in mf.keys():