Show More
@@ -11,9 +11,12 import heapq | |||||
11 |
|
11 | |||
12 | from .node import nullrev |
|
12 | from .node import nullrev | |
13 | from . import ( |
|
13 | from . import ( | |
|
14 | policy, | |||
14 | pycompat, |
|
15 | pycompat, | |
15 | ) |
|
16 | ) | |
16 |
|
17 | |||
|
18 | parsers = policy.importmod(r'parsers') | |||
|
19 | ||||
17 | def commonancestorsheads(pfunc, *nodes): |
|
20 | def commonancestorsheads(pfunc, *nodes): | |
18 | """Returns a set with the heads of all common ancestors of all nodes, |
|
21 | """Returns a set with the heads of all common ancestors of all nodes, | |
19 | heads(::nodes[0] and ::nodes[1] and ...) . |
|
22 | heads(::nodes[0] and ::nodes[1] and ...) . | |
@@ -379,3 +382,25 class lazyancestors(object): | |||||
379 | # free up memory. |
|
382 | # free up memory. | |
380 | self._containsiter = None |
|
383 | self._containsiter = None | |
381 | return False |
|
384 | return False | |
|
385 | ||||
|
386 | class rustlazyancestors(lazyancestors): | |||
|
387 | ||||
|
388 | def __init__(self, index, revs, stoprev=0, inclusive=False): | |||
|
389 | self._index = index | |||
|
390 | self._stoprev = stoprev | |||
|
391 | self._inclusive = inclusive | |||
|
392 | # no need to prefilter out init revs that are smaller than stoprev, | |||
|
393 | # it's done by rustlazyancestors constructor. | |||
|
394 | # we need to convert to a list, because our ruslazyancestors | |||
|
395 | # constructor (from C code) doesn't understand anything else yet | |||
|
396 | self._initrevs = initrevs = list(revs) | |||
|
397 | ||||
|
398 | self._containsseen = set() | |||
|
399 | self._containsiter = parsers.rustlazyancestors( | |||
|
400 | index, initrevs, stoprev, inclusive) | |||
|
401 | ||||
|
402 | def __iter__(self): | |||
|
403 | return parsers.rustlazyancestors(self._index, | |||
|
404 | self._initrevs, | |||
|
405 | self._stoprev, | |||
|
406 | self._inclusive) |
@@ -763,6 +763,10 class revlog(object): | |||||
763 | for r in revs: |
|
763 | for r in revs: | |
764 | checkrev(r) |
|
764 | checkrev(r) | |
765 | # and we're sure ancestors aren't filtered as well |
|
765 | # and we're sure ancestors aren't filtered as well | |
|
766 | if util.safehasattr(parsers, 'rustlazyancestors'): | |||
|
767 | return ancestor.rustlazyancestors( | |||
|
768 | self.index, revs, | |||
|
769 | stoprev=stoprev, inclusive=inclusive) | |||
766 | return ancestor.lazyancestors(self._uncheckedparentrevs, revs, |
|
770 | return ancestor.lazyancestors(self._uncheckedparentrevs, revs, | |
767 | stoprev=stoprev, inclusive=inclusive) |
|
771 | stoprev=stoprev, inclusive=inclusive) | |
768 |
|
772 |
General Comments 0
You need to be logged in to leave comments.
Login now