123 if x != nullrev and x in seen: |
123 if x != nullrev and x in seen: |
124 seen.add(i) |
124 seen.add(i) |
125 yield i |
125 yield i |
126 break |
126 break |
127 |
127 |
128 def revdescendants(repo, revs, followfirst): |
128 def _builddescendantsmap(repo, startrev, followfirst): |
|
129 """Build map of 'rev -> child revs', offset from startrev""" |
|
130 cl = repo.changelog |
|
131 nullrev = node.nullrev |
|
132 descmap = [[] for _rev in xrange(startrev, len(cl))] |
|
133 for currev in cl.revs(startrev + 1): |
|
134 p1rev, p2rev = cl.parentrevs(currev) |
|
135 if p1rev >= startrev: |
|
136 descmap[p1rev - startrev].append(currev) |
|
137 if not followfirst and p2rev != nullrev and p2rev >= startrev: |
|
138 descmap[p2rev - startrev].append(currev) |
|
139 return descmap |
|
140 |
|
141 def _genrevdescendantsofdepth(repo, revs, followfirst, startdepth, stopdepth): |
|
142 startrev = revs.min() |
|
143 descmap = _builddescendantsmap(repo, startrev, followfirst) |
|
144 def pfunc(rev): |
|
145 return descmap[rev - startrev] |
|
146 return _walkrevtree(pfunc, revs, startdepth, stopdepth, reverse=False) |
|
147 |
|
148 def revdescendants(repo, revs, followfirst, startdepth=None, stopdepth=None): |
129 """Like revlog.descendants() but supports additional options, includes |
149 """Like revlog.descendants() but supports additional options, includes |
130 the given revs themselves, and returns a smartset""" |
150 the given revs themselves, and returns a smartset |
131 gen = _genrevdescendants(repo, revs, followfirst) |
151 |
|
152 Scan ends at the stopdepth (exlusive) if specified. Revisions found |
|
153 earlier than the startdepth are omitted. |
|
154 """ |
|
155 if startdepth is None and stopdepth is None: |
|
156 gen = _genrevdescendants(repo, revs, followfirst) |
|
157 else: |
|
158 gen = _genrevdescendantsofdepth(repo, revs, followfirst, |
|
159 startdepth, stopdepth) |
132 return generatorset(gen, iterasc=True) |
160 return generatorset(gen, iterasc=True) |
133 |
161 |
134 def _reachablerootspure(repo, minroot, roots, heads, includepath): |
162 def _reachablerootspure(repo, minroot, roots, heads, includepath): |
135 """return (heads(::<roots> and ::<heads>)) |
163 """return (heads(::<roots> and ::<heads>)) |
136 |
164 |