comparison mercurial/ancestor.py @ 44491:fb16ad368606

rust: clean remains of direct-ffi code Since b55bec1ea972, the cext entry poitn have been removed, so we drop the code for consistency.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 10 Mar 2020 14:24:08 +0100
parents 9d2b2df2c2ba
children 89a2afe31e82
comparison
equal deleted inserted replaced
44490:b3991b72d9f1 44491:fb16ad368606
391 except StopIteration: 391 except StopIteration:
392 # Set to None to indicate fast-path can be used next time, and to 392 # Set to None to indicate fast-path can be used next time, and to
393 # free up memory. 393 # free up memory.
394 self._containsiter = None 394 self._containsiter = None
395 return False 395 return False
396
397
398 class rustlazyancestors(object):
399 def __init__(self, index, revs, stoprev=0, inclusive=False):
400 self._index = index
401 self._stoprev = stoprev
402 self._inclusive = inclusive
403 # no need to prefilter out init revs that are smaller than stoprev,
404 # it's done by rustlazyancestors constructor.
405 # we need to convert to a list, because our ruslazyancestors
406 # constructor (from C code) doesn't understand anything else yet
407 self._initrevs = initrevs = list(revs)
408
409 self._containsiter = parsers.rustlazyancestors(
410 index, initrevs, stoprev, inclusive
411 )
412
413 def __nonzero__(self):
414 """False if the set is empty, True otherwise.
415
416 It's better to duplicate this essentially trivial method than
417 to subclass lazyancestors
418 """
419 try:
420 next(iter(self))
421 return True
422 except StopIteration:
423 return False
424
425 def __iter__(self):
426 return parsers.rustlazyancestors(
427 self._index, self._initrevs, self._stoprev, self._inclusive
428 )
429
430 def __contains__(self, target):
431 return target in self._containsiter