[PATCH 4 of 6] revset: precompute _descendants()
Patrick Mezard
patrick at mezard.eu
Tue May 8 15:58:09 CDT 2012
# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1336509824 -7200
# Node ID 3d24bf6b15d03ed618b7a7b0e49e349e70a9c674
# Parent dbeeb20515c9b9225f74fc8491d516a7b6b2f48a
revset: precompute _descendants()
On mercurial repository:
first line total
* hg log -r 0:tip --follow
2.2 0.124s 2.628s
before 0.153s 3.048s
after 0.150s 2.369s
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -484,19 +484,26 @@
l.append(r)
return l
+ at precomputed
def _descendants(repo, subset, x, followfirst=False):
args = getset(repo, range(len(repo)), x)
- if not args:
- return []
- s = set(_revdescendants(repo, args, followfirst)) | set(args)
- return [r for r in subset if r in s]
+ s = set()
+ if args:
+ s = set(_revdescendants(repo, args, followfirst)) | set(args)
+ def fn(repo, subset, x):
+ if not s:
+ return []
+ return [r for r in subset if r in s]
+ return fn
+ at precomputed
def descendants(repo, subset, x):
"""``descendants(set)``
Changesets which are descendants of changesets in set.
"""
return _descendants(repo, subset, x)
+ at precomputed
def _firstdescendants(repo, subset, x):
# ``_firstdescendants(set)``
# Like ``descendants(set)`` but follows only the first parents.
More information about the Mercurial-devel
mailing list