equal
deleted
inserted
replaced
314 |
314 |
315 parentrevs = self._parentrevs |
315 parentrevs = self._parentrevs |
316 stoprev = self._stoprev |
316 stoprev = self._stoprev |
317 visit = collections.deque(revs) |
317 visit = collections.deque(revs) |
318 |
318 |
|
319 see = seen.add |
|
320 schedule = visit.append |
|
321 |
319 while visit: |
322 while visit: |
320 for parent in parentrevs(visit.popleft()): |
323 for parent in parentrevs(visit.popleft()): |
321 if parent >= stoprev and parent not in seen: |
324 if parent >= stoprev and parent not in seen: |
322 visit.append(parent) |
325 schedule(parent) |
323 seen.add(parent) |
326 see(parent) |
324 yield parent |
327 yield parent |
325 |
328 |
326 def __contains__(self, target): |
329 def __contains__(self, target): |
327 """Test whether target is an ancestor of self._initrevs.""" |
330 """Test whether target is an ancestor of self._initrevs.""" |
328 # Trying to do both __iter__ and __contains__ using the same visit |
331 # Trying to do both __iter__ and __contains__ using the same visit |
335 parentrevs = self._parentrevs |
338 parentrevs = self._parentrevs |
336 visit = self._containsvisit |
339 visit = self._containsvisit |
337 stoprev = self._stoprev |
340 stoprev = self._stoprev |
338 heappop = heapq.heappop |
341 heappop = heapq.heappop |
339 heappush = heapq.heappush |
342 heappush = heapq.heappush |
|
343 see = seen.add |
340 |
344 |
341 targetseen = False |
345 targetseen = False |
342 |
346 |
343 while visit and -visit[0] > target and not targetseen: |
347 while visit and -visit[0] > target and not targetseen: |
344 for parent in parentrevs(-heappop(visit)): |
348 for parent in parentrevs(-heappop(visit)): |
345 if parent < stoprev or parent in seen: |
349 if parent < stoprev or parent in seen: |
346 continue |
350 continue |
347 # We need to make sure we push all parents into the heap so |
351 # We need to make sure we push all parents into the heap so |
348 # that we leave it in a consistent state for future calls. |
352 # that we leave it in a consistent state for future calls. |
349 heappush(visit, -parent) |
353 heappush(visit, -parent) |
350 seen.add(parent) |
354 see(parent) |
351 if parent == target: |
355 if parent == target: |
352 targetseen = True |
356 targetseen = True |
353 |
357 |
354 return targetseen |
358 return targetseen |