comparison mercurial/context.py @ 21880:e6754f5e4cf7

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.
author Siddharth Agarwal <sid0@fb.com>
date Sat, 12 Jul 2014 17:59:03 -0700
parents 04f5b5e3792e
children 5809d62e7106
comparison
equal deleted inserted replaced
21879:090dcaaf3fff 21880:e6754f5e4cf7
69 69
70 This method is for internal use only and mainly exists to provide an 70 This method is for internal use only and mainly exists to provide an
71 object oriented way for other contexts to customize the manifest 71 object oriented way for other contexts to customize the manifest
72 generation. 72 generation.
73 """ 73 """
74 if match.always():
75 return self.manifest().copy()
76
77 if match.matchfn == match.exact:
78 return self.manifest().intersectfiles(match.files())
79
74 mf = self.manifest().copy() 80 mf = self.manifest().copy()
75 if match.always():
76 return mf
77 for fn in mf.keys(): 81 for fn in mf.keys():
78 if not match(fn): 82 if not match(fn):
79 del mf[fn] 83 del mf[fn]
80 return mf 84 return mf
81 85