##// END OF EJS Templates
dagop: factor out generator of ancestor nodes...
Yuya Nishihara -
r33078:fb663bd0 default
parent child Browse files
Show More
@@ -23,11 +23,14 b' generatorset = smartset.generatorset'
23 23 # possible maximum depth between null and wdir()
24 24 _maxlogdepth = 0x80000000
25 25
26 def _genrevancestors(repo, revs, followfirst, startdepth, stopdepth):
27 if followfirst:
28 cut = 1
29 else:
30 cut = None
26 def _walkrevtree(pfunc, revs, startdepth, stopdepth):
27 """Walk DAG using 'pfunc' from the given 'revs' nodes
28
29 'pfunc(rev)' should return the parent revisions of the given 'rev'.
30
31 Scan ends at the stopdepth (exlusive) if specified. Revisions found
32 earlier than the startdepth are omitted.
33 """
31 34 if startdepth is None:
32 35 startdepth = 0
33 36 if stopdepth is None:
@@ -37,13 +40,6 b' def _genrevancestors(repo, revs, followf'
37 40 if stopdepth < 0:
38 41 raise error.ProgrammingError('negative stopdepth')
39 42
40 cl = repo.changelog
41 def pfunc(rev):
42 try:
43 return cl.parentrevs(rev)[:cut]
44 except error.WdirUnsupported:
45 return (pctx.rev() for pctx in repo[rev].parents()[:cut])
46
47 43 # load input revs lazily to heap so earlier revisions can be yielded
48 44 # without fully computing the input revs
49 45 revs.sort(reverse=True)
@@ -74,6 +70,19 b' def _genrevancestors(repo, revs, followf'
74 70 if prev != node.nullrev:
75 71 heapq.heappush(pendingheap, (-prev, pdepth))
76 72
73 def _genrevancestors(repo, revs, followfirst, startdepth, stopdepth):
74 if followfirst:
75 cut = 1
76 else:
77 cut = None
78 cl = repo.changelog
79 def pfunc(rev):
80 try:
81 return cl.parentrevs(rev)[:cut]
82 except error.WdirUnsupported:
83 return (pctx.rev() for pctx in repo[rev].parents()[:cut])
84 return _walkrevtree(pfunc, revs, startdepth, stopdepth)
85
77 86 def revancestors(repo, revs, followfirst, startdepth=None, stopdepth=None):
78 87 """Like revlog.ancestors(), but supports additional options, includes
79 88 the given revs themselves, and returns a smartset
General Comments 0
You need to be logged in to leave comments. Login now