Show More
@@ -9,6 +9,9 b' from __future__ import absolute_import' | |||||
9 |
|
9 | |||
10 | import heapq |
|
10 | import heapq | |
11 |
|
11 | |||
|
12 | from .node import ( | |||
|
13 | nullrev, | |||
|
14 | ) | |||
12 | from .thirdparty import ( |
|
15 | from .thirdparty import ( | |
13 | attr, |
|
16 | attr, | |
14 | ) |
|
17 | ) | |
@@ -225,6 +228,37 b' def revdescendants(repo, revs, followfir' | |||||
225 | startdepth, stopdepth) |
|
228 | startdepth, stopdepth) | |
226 | return generatorset(gen, iterasc=True) |
|
229 | return generatorset(gen, iterasc=True) | |
227 |
|
230 | |||
|
231 | def descendantrevs(revs, revsfn, parentrevsfn): | |||
|
232 | """Generate revision number descendants in revision order. | |||
|
233 | ||||
|
234 | Yields revision numbers starting with a child of some rev in | |||
|
235 | ``revs``. Results are ordered by revision number and are | |||
|
236 | therefore topological. Each revision is not considered a descendant | |||
|
237 | of itself. | |||
|
238 | ||||
|
239 | ``revsfn`` is a callable that with no argument iterates over all | |||
|
240 | revision numbers and with a ``start`` argument iterates over revision | |||
|
241 | numbers beginning with that value. | |||
|
242 | ||||
|
243 | ``parentrevsfn`` is a callable that receives a revision number and | |||
|
244 | returns an iterable of parent revision numbers, whose values may include | |||
|
245 | nullrev. | |||
|
246 | """ | |||
|
247 | first = min(revs) | |||
|
248 | ||||
|
249 | if first == nullrev: | |||
|
250 | for rev in revsfn(): | |||
|
251 | yield rev | |||
|
252 | return | |||
|
253 | ||||
|
254 | seen = set(revs) | |||
|
255 | for rev in revsfn(start=first + 1): | |||
|
256 | for prev in parentrevsfn(rev): | |||
|
257 | if prev != nullrev and prev in seen: | |||
|
258 | seen.add(rev) | |||
|
259 | yield rev | |||
|
260 | break | |||
|
261 | ||||
228 | def _reachablerootspure(repo, minroot, roots, heads, includepath): |
|
262 | def _reachablerootspure(repo, minroot, roots, heads, includepath): | |
229 | """return (heads(::<roots> and ::<heads>)) |
|
263 | """return (heads(::<roots> and ::<heads>)) | |
230 |
|
264 |
@@ -748,25 +748,7 b' class revlog(object):' | |||||
748 | inclusive=inclusive) |
|
748 | inclusive=inclusive) | |
749 |
|
749 | |||
750 | def descendants(self, revs): |
|
750 | def descendants(self, revs): | |
751 | """Generate the descendants of 'revs' in revision order. |
|
751 | return dagop.descendantrevs(revs, self.revs, self.parentrevs) | |
752 |
|
||||
753 | Yield a sequence of revision numbers starting with a child of |
|
|||
754 | some rev in revs, i.e., each revision is *not* considered a |
|
|||
755 | descendant of itself. Results are ordered by revision number (a |
|
|||
756 | topological sort).""" |
|
|||
757 | first = min(revs) |
|
|||
758 | if first == nullrev: |
|
|||
759 | for i in self: |
|
|||
760 | yield i |
|
|||
761 | return |
|
|||
762 |
|
||||
763 | seen = set(revs) |
|
|||
764 | for i in self.revs(start=first + 1): |
|
|||
765 | for x in self.parentrevs(i): |
|
|||
766 | if x != nullrev and x in seen: |
|
|||
767 | seen.add(i) |
|
|||
768 | yield i |
|
|||
769 | break |
|
|||
770 |
|
752 | |||
771 | def findcommonmissing(self, common=None, heads=None): |
|
753 | def findcommonmissing(self, common=None, heads=None): | |
772 | """Return a tuple of the ancestors of common and the ancestors of heads |
|
754 | """Return a tuple of the ancestors of common and the ancestors of heads |
General Comments 0
You need to be logged in to leave comments.
Login now