Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 28008:86c4cbdaffee
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'.
author | Durham Goode <durham@fb.com> |
---|---|
date | Fri, 05 Feb 2016 13:30:25 -0800 |
parents | 4186d359046a |
children | a036e1ae1fbe |
comparison
equal
deleted
inserted
replaced
28007:fb92927f9775 | 28008:86c4cbdaffee |
---|---|
1084 if l: | 1084 if l: |
1085 x = getstring(l[0], _("%s expected a pattern") % name) | 1085 x = getstring(l[0], _("%s expected a pattern") % name) |
1086 matcher = matchmod.match(repo.root, repo.getcwd(), [x], | 1086 matcher = matchmod.match(repo.root, repo.getcwd(), [x], |
1087 ctx=repo[None], default='path') | 1087 ctx=repo[None], default='path') |
1088 | 1088 |
1089 files = c.manifest().walk(matcher) | |
1090 | |
1089 s = set() | 1091 s = set() |
1090 for fname in c: | 1092 for fname in files: |
1091 if matcher(fname): | 1093 fctx = c[fname] |
1092 fctx = c[fname] | 1094 s = s.union(set(c.rev() for c in fctx.ancestors(followfirst))) |
1093 s = s.union(set(c.rev() for c in fctx.ancestors(followfirst))) | 1095 # include the revision responsible for the most recent version |
1094 # include the revision responsible for the most recent version | 1096 s.add(fctx.introrev()) |
1095 s.add(fctx.introrev()) | |
1096 else: | 1097 else: |
1097 s = _revancestors(repo, baseset([c.rev()]), followfirst) | 1098 s = _revancestors(repo, baseset([c.rev()]), followfirst) |
1098 | 1099 |
1099 return subset & s | 1100 return subset & s |
1100 | 1101 |