##// END OF EJS Templates
revset: changed ancestors revset to return lazy generators...
Lucas Moscovicz -
r20690:13c0327e default
parent child Browse files
Show More
@@ -8,6 +8,7 b''
8 8 import re
9 9 import parser, util, error, discovery, hbisect, phases
10 10 import node
11 import heapq
11 12 import match as matchmod
12 13 import ancestor as ancestormod
13 14 from i18n import _
@@ -20,14 +21,24 b' def _revancestors(repo, revs, followfirs'
20 21 """Like revlog.ancestors(), but supports followfirst."""
21 22 cut = followfirst and 1 or None
22 23 cl = repo.changelog
23 visit = util.deque(revs)
24
25 # Implementation to be changed in later patches based on revs order.
26 h = list(revs)
27 for i in xrange(len(h)):
28 h[i] = -h[i]
29 heapq.heapify(h)
24 30 seen = set([node.nullrev])
25 while visit:
26 for parent in cl.parentrevs(visit.popleft())[:cut]:
27 if parent not in seen:
28 visit.append(parent)
29 seen.add(parent)
30 yield parent
31 def iterate():
32 while h:
33 current = -heapq.heappop(h)
34 if current not in seen:
35 seen.add(current)
36 yield current
37 for parent in cl.parentrevs(current)[:cut]:
38 if parent != node.nullrev:
39 heapq.heappush(h, -parent)
40
41 return descgeneratorset(iterate())
31 42
32 43 def _revdescendants(repo, revs, followfirst):
33 44 """Like revlog.descendants() but supports followfirst."""
@@ -312,7 +323,7 b' def _ancestors(repo, subset, x, followfi'
312 323 args = getset(repo, spanset(repo), x)
313 324 if not args:
314 325 return baseset([])
315 s = set(_revancestors(repo, args, followfirst)) | set(args)
326 s = _revancestors(repo, args, followfirst)
316 327 return subset.filter(lambda r: r in s)
317 328
318 329 def ancestors(repo, subset, x):
@@ -784,7 +795,7 b' def _follow(repo, subset, x, name, follo'
784 795 else:
785 796 return baseset([])
786 797 else:
787 s = set(_revancestors(repo, [c.rev()], followfirst)) | set([c.rev()])
798 s = _revancestors(repo, baseset([c.rev()]), followfirst)
788 799
789 800 return subset.filter(lambda r: r in s)
790 801
General Comments 0
You need to be logged in to leave comments. Login now