##// END OF EJS Templates
dagop: use heap to compute max rev in filectxancestors()
Yuya Nishihara -
r35298:c9144396 default
parent child Browse files
Show More
@@ -82,10 +82,12 b' def filectxancestors(fctxs, followfirst='
82 82 Yields (rev, {fctx, ...}) pairs in descending order.
83 83 """
84 84 visit = {}
85 visitheap = []
85 86 def addvisit(fctx):
86 87 rev = fctx.rev()
87 88 if rev not in visit:
88 89 visit[rev] = set()
90 heapq.heappush(visitheap, -rev) # max heap
89 91 visit[rev].add(fctx)
90 92
91 93 if followfirst:
@@ -96,12 +98,13 b' def filectxancestors(fctxs, followfirst='
96 98 for c in fctxs:
97 99 addvisit(c)
98 100 while visit:
99 currev = max(visit)
101 currev = -heapq.heappop(visitheap)
100 102 curfctxs = visit.pop(currev)
101 103 yield currev, curfctxs
102 104 for c in curfctxs:
103 105 for parent in c.parents()[:cut]:
104 106 addvisit(parent)
107 assert not visitheap
105 108
106 109 def filerevancestors(fctxs, followfirst=False):
107 110 """Like filectx.ancestors(), but can walk from multiple files/revisions,
General Comments 0
You need to be logged in to leave comments. Login now