##// END OF EJS Templates
revset: changed descendants revset to use lazy generators...
Lucas Moscovicz -
r20692:7af34108 default
parent child Browse files
Show More
@@ -51,23 +51,26 b' def _revancestors(repo, revs, followfirs'
51 def _revdescendants(repo, revs, followfirst):
51 def _revdescendants(repo, revs, followfirst):
52 """Like revlog.descendants() but supports followfirst."""
52 """Like revlog.descendants() but supports followfirst."""
53 cut = followfirst and 1 or None
53 cut = followfirst and 1 or None
54 cl = repo.changelog
55 first = min(revs)
56 nullrev = node.nullrev
57 if first == nullrev:
58 # Are there nodes with a null first parent and a non-null
59 # second one? Maybe. Do we care? Probably not.
60 for i in cl:
61 yield i
62 return
63
54
64 seen = set(revs)
55 def iterate():
65 for i in cl.revs(first + 1):
56 cl = repo.changelog
66 for x in cl.parentrevs(i)[:cut]:
57 first = min(revs)
67 if x != nullrev and x in seen:
58 nullrev = node.nullrev
68 seen.add(i)
59 if first == nullrev:
60 # Are there nodes with a null first parent and a non-null
61 # second one? Maybe. Do we care? Probably not.
62 for i in cl:
69 yield i
63 yield i
70 break
64 else:
65 seen = set(revs)
66 for i in cl.revs(first + 1):
67 for x in cl.parentrevs(i)[:cut]:
68 if x != nullrev and x in seen:
69 seen.add(i)
70 yield i
71 break
72
73 return ascgeneratorset(iterate())
71
74
72 def _revsbetween(repo, roots, heads):
75 def _revsbetween(repo, roots, heads):
73 """Return all paths between roots and heads, inclusive of both endpoint
76 """Return all paths between roots and heads, inclusive of both endpoint
@@ -641,8 +644,9 b' def _descendants(repo, subset, x, follow'
641 args = getset(repo, spanset(repo), x)
644 args = getset(repo, spanset(repo), x)
642 if not args:
645 if not args:
643 return baseset([])
646 return baseset([])
644 s = set(_revdescendants(repo, args, followfirst)) | set(args)
647 s = _revdescendants(repo, args, followfirst)
645 return subset & s
648 a = set(args)
649 return subset.filter(lambda r: r in s or r in a)
646
650
647 def descendants(repo, subset, x):
651 def descendants(repo, subset, x):
648 """``descendants(set)``
652 """``descendants(set)``
General Comments 0
You need to be logged in to leave comments. Login now