Patchwork [4,of,4] revset: changed _children method to use lazy structures

login
register
mail settings
Submitter Lucas Moscovicz
Date March 6, 2014, 11:19 p.m.
Message ID <4017b7844aa1a890f10e.1394147959@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3883/
State Accepted
Commit d04aac468bf45f7c046447f8264badab095436ac
Headers show

Comments

Lucas Moscovicz - March 6, 2014, 11:19 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1392156223 28800
#      Tue Feb 11 14:03:43 2014 -0800
# Node ID 4017b7844aa1a890f10e06d3c79322bd946dca3f
# Parent  f91f466dd6b238140ee96d523b7a2476d324c23c
revset: changed _children method to use lazy structures
Matt Mackall - March 12, 2014, 9 p.m.
On Thu, 2014-03-06 at 15:19 -0800, Lucas Moscovicz wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz@fb.com>
> # Date 1392156223 28800
> #      Tue Feb 11 14:03:43 2014 -0800
> # Node ID 4017b7844aa1a890f10e06d3c79322bd946dca3f
> # Parent  f91f466dd6b238140ee96d523b7a2476d324c23c
> revset: changed _children method to use lazy structures

These are queued for default, thanks.

Patch

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)``