Mercurial > hg
changeset 15899:476a981fdf34
revset: optimize roots and children
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 16 Jan 2012 01:21:30 -0600 |
parents | 6902e13ddd03 |
children | 73c4b3d0c711 |
files | mercurial/revset.py |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Mon Jan 16 01:21:22 2012 -0600 +++ b/mercurial/revset.py Mon Jan 16 01:21:30 2012 -0600 @@ -321,17 +321,22 @@ break return s +def _children(repo, narrow, s): + cs = set() + pr = repo.changelog.parentrevs + s = set(s) + for r in narrow: + for p in pr(r): + if p in s: + cs.add(r) + return cs + def children(repo, subset, x): """``children(set)`` Child changesets of changesets in set. """ - cs = set() - cl = repo.changelog - s = set(getset(repo, range(len(repo)), x)) - for r in xrange(0, len(repo)): - for p in cl.parentrevs(r): - if p in s: - cs.add(r) + s = getset(repo, range(len(repo)), x) + cs = _children(repo, subset, s) return [r for r in subset if r in cs] def closed(repo, subset, x): @@ -772,7 +777,7 @@ Changesets with no parent changeset in set. """ s = getset(repo, subset, x) - cs = set(children(repo, subset, x)) + cs = _children(repo, s, s) return [r for r in s if r not in cs] def secret(repo, subset, x):