mercurial/dagop.py
changeset 35285 205c3c6c1a51
parent 35284 b4b328ea6175
child 35305 2cb05e6043be
equal deleted inserted replaced
35284:b4b328ea6175 35285:205c3c6c1a51
    73         if foundnew and pdepth < stopdepth:
    73         if foundnew and pdepth < stopdepth:
    74             for prev in pfunc(currev):
    74             for prev in pfunc(currev):
    75                 if prev != node.nullrev:
    75                 if prev != node.nullrev:
    76                     heapq.heappush(pendingheap, (heapsign * prev, pdepth))
    76                     heapq.heappush(pendingheap, (heapsign * prev, pdepth))
    77 
    77 
    78 def filectxancestors(fctx, followfirst=False):
    78 def filectxancestors(fctxs, followfirst=False):
    79     """Like filectx.ancestors(), but includes the given fctx itself"""
    79     """Like filectx.ancestors(), but can walk from multiple files/revisions,
       
    80     and includes the given fctxs themselves"""
    80     visit = {}
    81     visit = {}
    81     def addvisit(fctx):
    82     def addvisit(fctx):
    82         rev = fctx.rev()
    83         rev = fctx.rev()
    83         if rev not in visit:
    84         if rev not in visit:
    84             visit[rev] = set()
    85             visit[rev] = set()
    87     if followfirst:
    88     if followfirst:
    88         cut = 1
    89         cut = 1
    89     else:
    90     else:
    90         cut = None
    91         cut = None
    91 
    92 
    92     addvisit(fctx)
    93     for c in fctxs:
       
    94         addvisit(c)
    93     while visit:
    95     while visit:
    94         rev = max(visit)
    96         rev = max(visit)
    95         c = visit[rev].pop()
    97         c = visit[rev].pop()
    96         if not visit[rev]:
    98         if not visit[rev]:
    97             del visit[rev]
    99             del visit[rev]