From patchwork Fri Aug 7 18:35:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6,of,6,V4] revsbetween: default to the C implementation From: Laurent Charignon X-Patchwork-Id: 10149 Message-Id: <40e991490a84e374f4c0.1438972554@dev919.prn2.facebook.com> To: Date: Fri, 7 Aug 2015 11:35:54 -0700 # HG changeset patch # User Laurent Charignon # Date 1438924280 25200 # Thu Aug 06 22:11:20 2015 -0700 # Branch stable # Node ID 40e991490a84e374f4c051d1b425797e168d1faf # Parent fc1351d02b62f64f628b363a598216e098b6fade revsbetween: default to the C implementation 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. Before this patch, revsbetween was computed in pure Python by default. This patch makes the C implementation the default and provides a speedup for revsbetween. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -78,19 +78,13 @@ return generatorset(iterate(), iterasc=True) -def revsbetween(repo, roots, heads, includepath=True): - """Return all paths between roots and heads, inclusive of both endpoint - sets.""" - if not roots: - return baseset() +def revsbetweenpure(repo, minroot, roots, heads, includepath): parentrevs = repo.changelog.parentrevs visit = list(heads) reachable = set() seen = {} # XXX this should be 'parentset.min()' assuming 'parentset' is a smartset # (and if it is not, it should.) - minroot = min(roots) - roots = set(roots) # prefetch all the things! (because python is slow) reached = reachable.add dovisit = visit.append @@ -118,6 +112,19 @@ reached(rev) return baseset(sorted(reachable)) +def revsbetween(repo, roots, heads, includepath=True): + """Return all paths between roots and heads, inclusive of both endpoint + sets.""" + if not roots: + return baseset() + minroot = min(roots) + roots = set(roots) + heads = list(heads) + try: + return repo.changelog.revsbetween(minroot, heads, roots, includepath) + except AttributeError: + return revsbetweenpure(repo, minroot, roots, heads, includepath) + elements = { # token-type: binding-strength, primary, prefix, infix, suffix "(": (21, None, ("group", 1, ")"), ("func", 1, ")"), None),