Mercurial > hg
changeset 35274:2b348dc3239a
dagop: change visit dict of filectxancestors() indexed solely by rev
In future patches, a max heap will be used to compute the next revision
to visit.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 22 Sep 2016 18:11:37 +0900 |
parents | 8dee2080f35c |
children | b4b328ea6175 |
files | mercurial/dagop.py |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dagop.py Thu Sep 22 18:01:55 2016 +0900 +++ b/mercurial/dagop.py Thu Sep 22 18:11:37 2016 +0900 @@ -78,6 +78,12 @@ def filectxancestors(fctx, followfirst=False): """Like filectx.ancestors(), but includes the given fctx itself""" visit = {} + def addvisit(fctx): + rev = fctx.rev() + if rev not in visit: + visit[rev] = set() + visit[rev].add(fctx) + c = fctx if followfirst: cut = 1 @@ -87,10 +93,13 @@ yield c while True: for parent in c.parents()[:cut]: - visit[(parent.rev(), parent.filenode())] = parent + addvisit(parent) if not visit: break - c = visit.pop(max(visit)) + rev = max(visit) + c = visit[rev].pop() + if not visit[rev]: + del visit[rev] yield c def _genrevancestors(repo, revs, followfirst, startdepth, stopdepth, cutfunc):