# HG changeset patch # User Durham Goode # Date 1454707825 28800 # Node ID 86c4cbdaffeeb75b9f0298774ce6b3db8d5aa0aa # Parent fb92927f977526795e9141e02141b589ebac902f revset: use manifest.matches in _follow revset The old _follow revset iterated over every file in the commit and checked if it matched. For repos with large manifests, this could take 500ms. By switching to use manifest.matches() we can take advantage of the fastpaths built in to manifest.py that allows iterating over only the files in the matcher when it's a simple matcher. This brings the time spent down from 500ms to 0ms during simple operations like 'hg log -f file.txt'. diff -r fb92927f9775 -r 86c4cbdaffee mercurial/revset.py --- a/mercurial/revset.py Thu Feb 04 08:34:07 2016 -0800 +++ b/mercurial/revset.py Fri Feb 05 13:30:25 2016 -0800 @@ -1086,13 +1086,14 @@ matcher = matchmod.match(repo.root, repo.getcwd(), [x], ctx=repo[None], default='path') + files = c.manifest().walk(matcher) + s = set() - for fname in c: - if matcher(fname): - fctx = c[fname] - s = s.union(set(c.rev() for c in fctx.ancestors(followfirst))) - # include the revision responsible for the most recent version - s.add(fctx.introrev()) + for fname in files: + fctx = c[fname] + s = s.union(set(c.rev() for c in fctx.ancestors(followfirst))) + # include the revision responsible for the most recent version + s.add(fctx.introrev()) else: s = _revancestors(repo, baseset([c.rev()]), followfirst)