Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20713:6a1a4c212d50
revset: improve head revset performance
Previously the head() revset would iterate over every item in the subset and
check if it was a head. Since the subset is often the entire repo, this was
slow on large repos. Now we iterate over each item in the head list and check if
it's in the subset, which results in much less work.
hg log -r 'head()' on a large repo:
Before: 0.95s
After: 0.28s
author | Durham Goode <durham@fb.com> |
---|---|
date | Thu, 13 Mar 2014 13:47:21 -0700 |
parents | c152e538b85b |
children | 41e1064486f9 |
comparison
equal
deleted
inserted
replaced
20712:c152e538b85b | 20713:6a1a4c212d50 |
---|---|
938 # i18n: "head" is a keyword | 938 # i18n: "head" is a keyword |
939 getargs(x, 0, 0, _("head takes no arguments")) | 939 getargs(x, 0, 0, _("head takes no arguments")) |
940 hs = set() | 940 hs = set() |
941 for b, ls in repo.branchmap().iteritems(): | 941 for b, ls in repo.branchmap().iteritems(): |
942 hs.update(repo[h].rev() for h in ls) | 942 hs.update(repo[h].rev() for h in ls) |
943 return subset.filter(lambda r: r in hs) | 943 return baseset(hs).filter(subset.__contains__) |
944 | 944 |
945 def heads(repo, subset, x): | 945 def heads(repo, subset, x): |
946 """``heads(set)`` | 946 """``heads(set)`` |
947 Members of set with no children in set. | 947 Members of set with no children in set. |
948 """ | 948 """ |