##// END OF EJS Templates
dagop: unnest inner generator of revdescendants()...
Yuya Nishihara -
r33073:b04cf7a6 default
parent child Browse files
Show More
@@ -84,34 +84,35 b' def revancestors(repo, revs, followfirst'
84 gen = _genrevancestors(repo, revs, followfirst, startdepth, stopdepth)
84 gen = _genrevancestors(repo, revs, followfirst, startdepth, stopdepth)
85 return generatorset(gen, iterasc=False)
85 return generatorset(gen, iterasc=False)
86
86
87 def revdescendants(repo, revs, followfirst):
87 def _genrevdescendants(repo, revs, followfirst):
88 """Like revlog.descendants() but supports followfirst."""
89 if followfirst:
88 if followfirst:
90 cut = 1
89 cut = 1
91 else:
90 else:
92 cut = None
91 cut = None
93
92
94 def iterate():
93 cl = repo.changelog
95 cl = repo.changelog
94 # XXX this should be 'parentset.min()' assuming 'parentset' is a
96 # XXX this should be 'parentset.min()' assuming 'parentset' is a
95 # smartset (and if it is not, it should.)
97 # smartset (and if it is not, it should.)
96 first = min(revs)
98 first = min(revs)
97 nullrev = node.nullrev
99 nullrev = node.nullrev
98 if first == nullrev:
100 if first == nullrev:
99 # Are there nodes with a null first parent and a non-null
101 # Are there nodes with a null first parent and a non-null
100 # second one? Maybe. Do we care? Probably not.
102 # second one? Maybe. Do we care? Probably not.
101 for i in cl:
103 for i in cl:
102 yield i
104 yield i
103 else:
105 else:
104 seen = set(revs)
106 seen = set(revs)
105 for i in cl.revs(first + 1):
107 for i in cl.revs(first + 1):
106 for x in cl.parentrevs(i)[:cut]:
108 for x in cl.parentrevs(i)[:cut]:
107 if x != nullrev and x in seen:
109 if x != nullrev and x in seen:
108 seen.add(i)
110 seen.add(i)
109 yield i
111 yield i
110 break
112 break
113
111
114 return generatorset(iterate(), iterasc=True)
112 def revdescendants(repo, revs, followfirst):
113 """Like revlog.descendants() but supports followfirst."""
114 gen = _genrevdescendants(repo, revs, followfirst)
115 return generatorset(gen, iterasc=True)
115
116
116 def _reachablerootspure(repo, minroot, roots, heads, includepath):
117 def _reachablerootspure(repo, minroot, roots, heads, includepath):
117 """return (heads(::<roots> and ::<heads>))
118 """return (heads(::<roots> and ::<heads>))
General Comments 0
You need to be logged in to leave comments. Login now