From patchwork Thu Mar 6 23:19:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,4] revset: changed _children method to use lazy structures From: Lucas Moscovicz X-Patchwork-Id: 3883 Message-Id: <4017b7844aa1a890f10e.1394147959@dev1037.prn2.facebook.com> To: mercurial-devel@selenic.com Date: Thu, 06 Mar 2014 15:19:19 -0800 # HG changeset patch # User Lucas Moscovicz # Date 1392156223 28800 # Tue Feb 11 14:03:43 2014 -0800 # Node ID 4017b7844aa1a890f10e06d3c79322bd946dca3f # Parent f91f466dd6b238140ee96d523b7a2476d324c23c revset: changed _children method to use lazy structures diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -540,18 +540,19 @@ return subset.filter(matches) def _children(repo, narrow, parentset): - cs = set() if not parentset: - return baseset(cs) + return baseset([]) pr = repo.changelog.parentrevs minrev = min(parentset) - for r in narrow: - if r <= minrev: - continue - for p in pr(r): + + def matches(x): + if x <= minrev: + return False + for p in pr(x): if p in parentset: - cs.add(r) - return baseset(cs) + return True + + return narrow.filter(matches) def children(repo, subset, x): """``children(set)``