##// END OF EJS Templates
dagop: extend filectxancestors() to walk multiple files
Yuya Nishihara -
r35277:205c3c6c default
parent child Browse files
Show More
@@ -75,8 +75,9 b' def _walkrevtree(pfunc, revs, startdepth'
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()
@@ -89,7 +90,8 b' def filectxancestors(fctx, followfirst=F'
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()
@@ -927,11 +927,9 b' def _follow(repo, subset, x, name, follo'
927
927
928 files = c.manifest().walk(matcher)
928 files = c.manifest().walk(matcher)
929
929
930 s = set()
930 fctxs = [c[f].introfilectx() for f in files]
931 for fname in files:
931 a = dagop.filectxancestors(fctxs, followfirst)
932 fctx = c[fname].introfilectx()
932 s = set(c.rev() for c in a)
933 a = dagop.filectxancestors(fctx, followfirst)
934 s = s.union(set(c.rev() for c in a))
935 else:
933 else:
936 s = dagop.revancestors(repo, baseset([c.rev()]), followfirst)
934 s = dagop.revancestors(repo, baseset([c.rev()]), followfirst)
937
935
General Comments 0
You need to be logged in to leave comments. Login now