Mercurial > hg
changeset 33077:58ebb38456e0
dagop: factor out pfunc from revancestors() generator
This generator will be reused for tracking descendants with depth limit.
# ancestors(tip) using hg repo
0) 0.065868
1) 0.068976
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 24 Jun 2017 23:22:45 +0900 |
parents | a76a64c78807 |
children | fb663bd0243f |
files | mercurial/dagop.py |
diffstat | 1 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dagop.py Fri Jun 23 21:15:10 2017 +0900 +++ b/mercurial/dagop.py Sat Jun 24 23:22:45 2017 +0900 @@ -38,6 +38,11 @@ raise error.ProgrammingError('negative stopdepth') cl = repo.changelog + def pfunc(rev): + try: + return cl.parentrevs(rev)[:cut] + except error.WdirUnsupported: + return (pctx.rev() for pctx in repo[rev].parents()[:cut]) # load input revs lazily to heap so earlier revisions can be yielded # without fully computing the input revs @@ -65,14 +70,9 @@ yield currev pdepth = curdepth + 1 if foundnew and pdepth < stopdepth: - try: - for prev in cl.parentrevs(currev)[:cut]: - if prev != node.nullrev: - heapq.heappush(pendingheap, (-prev, pdepth)) - except error.WdirUnsupported: - for pctx in repo[currev].parents()[:cut]: - if pctx.rev() != node.nullrev: - heapq.heappush(pendingheap, (-pctx.rev(), pdepth)) + for prev in pfunc(currev): + if prev != node.nullrev: + heapq.heappush(pendingheap, (-prev, pdepth)) def revancestors(repo, revs, followfirst, startdepth=None, stopdepth=None): """Like revlog.ancestors(), but supports additional options, includes