# HG changeset patch # User Siddharth Agarwal # Date 1405547583 25200 # Node ID 5809d62e7106a80cc8087bc8f1e76fbfe1f9b141 # Parent 1000348b3aea889b8fb16715297e175e1aab5c82 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 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. diff -r 1000348b3aea -r 5809d62e7106 mercurial/context.py --- 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():