# HG changeset patch # User Laurent Charignon # Date 1434770334 25200 # Node ID fd92bfbbe02d9eabf156735c204104c3022182db # Parent 748053b4a66ba40a062526a09fc421bd448d5bef revset: rename revsbetween to reachableroots and add an argument This patch is part of a series of patches to speed up the computation of revset.revsbetween by introducing a C implementation. The main motivation is to speed up smartlog on big repositories. At the end of the series, on our big repositories the computation of revsbetween is 10-50x faster and smartlog on is 2x-5x faster. This patch rename 'revsbetween' to 'reachableroots' and makes the computation of the full path optional. This will allow graphlog to compute grandparents using 'reachableroots' and remove the need for a dedicated grandparent function. diff -r 748053b4a66b -r fd92bfbbe02d mercurial/revset.py --- a/mercurial/revset.py Fri Aug 07 02:13:42 2015 -0700 +++ b/mercurial/revset.py Fri Jun 19 20:18:54 2015 -0700 @@ -87,9 +87,10 @@ return generatorset(iterate(), iterasc=True) -def revsbetween(repo, roots, heads): - """Return all paths between roots and heads, inclusive of both endpoint - sets.""" +def reachableroots(repo, roots, heads, includepath=False): + """return (heads(:: and ::)) + + If includepath is True, return (::).""" if not roots: return baseset() parentrevs = repo.changelog.parentrevs @@ -110,6 +111,8 @@ rev = nextvisit() if rev in roots: reached(rev) + if not includepath: + continue parents = parentrevs(rev) seen[rev] = parents for parent in parents: @@ -117,6 +120,8 @@ dovisit(parent) if not reachable: return baseset() + if not includepath: + return reachable for rev in sorted(seen): for parent in seen[rev]: if parent in reachable: @@ -406,7 +411,8 @@ def dagrange(repo, subset, x, y): r = fullreposet(repo) - xs = revsbetween(repo, getset(repo, r, x), getset(repo, r, y)) + xs = reachableroots(repo, getset(repo, r, x), getset(repo, r, y), + includepath=True) # XXX We should combine with subset first: 'subset & baseset(...)'. This is # necessary to ensure we preserve the order in subset. return xs & subset