[PATCH 3 of 6 V2] revset: remove grandparent by using revsbetween
Laurent Charignon
lcharignon at fb.com
Fri Aug 7 09:28:20 UTC 2015
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1434770932 25200
# Fri Jun 19 20:28:52 2015 -0700
# Branch stable
# Node ID 4d1b9f4def5070ac3a09dbeb396b745237a49417
# Parent 812d9212f1474df436453d08b7c71a44549524a3
revset: remove grandparent by using revsbetween
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, we had a custom computation for grandparent that was very
close to the idea of revsbetween. This patch expresses grandparent with
revsbetween to reduce the amount of code.
diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py
--- a/mercurial/graphmod.py
+++ b/mercurial/graphmod.py
@@ -19,6 +19,7 @@
from mercurial.node import nullrev
import util
+import revset
import heapq
@@ -233,8 +234,6 @@
if not revs:
return
- cl = repo.changelog
- lowestrev = revs.min()
gpcache = {}
if repo.ui.configbool('experimental', 'graph-group-branches', False):
@@ -256,7 +255,8 @@
for mpar in mpars:
gp = gpcache.get(mpar)
if gp is None:
- gp = gpcache[mpar] = grandparent(cl, lowestrev, revs, mpar)
+ gp = gpcache[mpar] = revset.revsbetween(repo, revs, [mpar],
+ includepath=False)
if not gp:
parents.append(mpar)
else:
@@ -354,24 +354,6 @@
yield (cur, type, data, (col, color), edges)
seen = next
-def grandparent(cl, lowestrev, roots, head):
- """Return all ancestors of head in roots which revision is
- greater or equal to lowestrev.
- """
- pending = set([head])
- seen = set()
- kept = set()
- llowestrev = max(nullrev, lowestrev)
- while pending:
- r = pending.pop()
- if r >= llowestrev and r not in seen:
- if r in roots:
- kept.add(r)
- else:
- pending.update([p for p in cl.parentrevs(r)])
- seen.add(r)
- return sorted(kept)
-
def asciiedges(type, char, lines, seen, rev, parents):
"""adds edge info to changelog DAG walk suitable for ascii()"""
if rev not in seen:
More information about the Mercurial-devel
mailing list