# HG changeset patch # User Durham Goode # Date 1394743641 25200 # Node ID 6a1a4c212d50b761c9abffabbd988d68aa95f607 # Parent c152e538b85b099ce20b51104b8b7dd3666aad7c 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 diff -r c152e538b85b -r 6a1a4c212d50 mercurial/revset.py --- a/mercurial/revset.py Tue Mar 11 16:52:15 2014 -0700 +++ b/mercurial/revset.py Thu Mar 13 13:47:21 2014 -0700 @@ -940,7 +940,7 @@ hs = set() for b, ls in repo.branchmap().iteritems(): hs.update(repo[h].rev() for h in ls) - return subset.filter(lambda r: r in hs) + return baseset(hs).filter(subset.__contains__) def heads(repo, subset, x): """``heads(set)``