##// END OF EJS Templates
revset: optimized _revancestors method based on order of revisions...
Lucas Moscovicz -
r20691:c1f666e2 default
parent child Browse files
Show More
@@ -22,16 +22,24 b' def _revancestors(repo, revs, followfirs'
22 cut = followfirst and 1 or None
22 cut = followfirst and 1 or None
23 cl = repo.changelog
23 cl = repo.changelog
24
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)
30 seen = set([node.nullrev])
31 def iterate():
25 def iterate():
26 revqueue, revsnode = None, None
27 h = []
28
29 revs.descending()
30 revqueue = util.deque(revs)
31 if revqueue:
32 revsnode = revqueue.popleft()
33 heapq.heappush(h, -revsnode)
34
35 seen = set([node.nullrev])
32 while h:
36 while h:
33 current = -heapq.heappop(h)
37 current = -heapq.heappop(h)
34 if current not in seen:
38 if current not in seen:
39 if revsnode and current == revsnode:
40 if revqueue:
41 revsnode = revqueue.popleft()
42 heapq.heappush(h, -revsnode)
35 seen.add(current)
43 seen.add(current)
36 yield current
44 yield current
37 for parent in cl.parentrevs(current)[:cut]:
45 for parent in cl.parentrevs(current)[:cut]:
General Comments 0
You need to be logged in to leave comments. Login now