Show More
@@ -409,7 +409,7 b' def only(repo, subset, x):' | |||||
409 | exclude = getset(repo, spanset(repo), args[1]) |
|
409 | exclude = getset(repo, spanset(repo), args[1]) | |
410 |
|
410 | |||
411 | results = set(ancestormod.missingancestors(include, exclude, cl.parentrevs)) |
|
411 | results = set(ancestormod.missingancestors(include, exclude, cl.parentrevs)) | |
412 |
return |
|
412 | return filteredset(subset, results.__contains__) | |
413 |
|
413 | |||
414 | def bisect(repo, subset, x): |
|
414 | def bisect(repo, subset, x): | |
415 | """``bisect(string)`` |
|
415 | """``bisect(string)`` | |
@@ -668,8 +668,8 b' def _descendants(repo, subset, x, follow' | |||||
668 | result = (orderedlazyset(s, subset.__contains__, ascending=True) + |
|
668 | result = (orderedlazyset(s, subset.__contains__, ascending=True) + | |
669 | orderedlazyset(args, subset.__contains__, ascending=True)) |
|
669 | orderedlazyset(args, subset.__contains__, ascending=True)) | |
670 |
|
670 | |||
671 |
# Wrap result in a |
|
671 | # Wrap result in a filteredset since it's an _addset, which doesn't | |
672 | # all the necessary functions to be consumed by callers. |
|
672 | # implement all the necessary functions to be consumed by callers. | |
673 | return orderedlazyset(result, lambda r: True, ascending=True) |
|
673 | return orderedlazyset(result, lambda r: True, ascending=True) | |
674 |
|
674 | |||
675 | def descendants(repo, subset, x): |
|
675 | def descendants(repo, subset, x): | |
@@ -2330,7 +2330,7 b' class baseset(list, abstractsmartset):' | |||||
2330 |
|
2330 | |||
2331 | This is part of the mandatory API for smartset.""" |
|
2331 | This is part of the mandatory API for smartset.""" | |
2332 | # If we are operating on 2 baseset, do the computation now since all |
|
2332 | # If we are operating on 2 baseset, do the computation now since all | |
2333 |
# data is available. The alternative is to involve a |
|
2333 | # data is available. The alternative is to involve a filteredset, which | |
2334 | # may be slow. |
|
2334 | # may be slow. | |
2335 | if isinstance(other, baseset): |
|
2335 | if isinstance(other, baseset): | |
2336 | other = other.set() |
|
2336 | other = other.set() | |
@@ -2371,7 +2371,7 b' class baseset(list, abstractsmartset):' | |||||
2371 | boolean. |
|
2371 | boolean. | |
2372 |
|
2372 | |||
2373 | This is part of the mandatory API for smartset.""" |
|
2373 | This is part of the mandatory API for smartset.""" | |
2374 |
return |
|
2374 | return filteredset(self, condition) | |
2375 |
|
2375 | |||
2376 | class _orderedsetmixin(object): |
|
2376 | class _orderedsetmixin(object): | |
2377 | """Mixin class with utility methods for smartsets |
|
2377 | """Mixin class with utility methods for smartsets | |
@@ -2404,7 +2404,7 b' class _orderedsetmixin(object):' | |||||
2404 | return self._last() |
|
2404 | return self._last() | |
2405 | return self._first() |
|
2405 | return self._first() | |
2406 |
|
2406 | |||
2407 |
class |
|
2407 | class filteredset(abstractsmartset): | |
2408 | """Duck type for baseset class which iterates lazily over the revisions in |
|
2408 | """Duck type for baseset class which iterates lazily over the revisions in | |
2409 | the subset and contains a function which tests for membership in the |
|
2409 | the subset and contains a function which tests for membership in the | |
2410 | revset |
|
2410 | revset | |
@@ -2452,10 +2452,10 b' class lazyset(abstractsmartset):' | |||||
2452 | return lambda: self._iterfilter(it()) |
|
2452 | return lambda: self._iterfilter(it()) | |
2453 |
|
2453 | |||
2454 | def __and__(self, x): |
|
2454 | def __and__(self, x): | |
2455 |
return |
|
2455 | return filteredset(self, x.__contains__) | |
2456 |
|
2456 | |||
2457 | def __sub__(self, x): |
|
2457 | def __sub__(self, x): | |
2458 |
return |
|
2458 | return filteredset(self, lambda r: r not in x) | |
2459 |
|
2459 | |||
2460 | def __add__(self, x): |
|
2460 | def __add__(self, x): | |
2461 | return _addset(self, x) |
|
2461 | return _addset(self, x) | |
@@ -2499,10 +2499,10 b' class lazyset(abstractsmartset):' | |||||
2499 | return self._ascending is not None and not self._ascending |
|
2499 | return self._ascending is not None and not self._ascending | |
2500 |
|
2500 | |||
2501 | def filter(self, l): |
|
2501 | def filter(self, l): | |
2502 |
return |
|
2502 | return filteredset(self, l) | |
2503 |
|
2503 | |||
2504 |
class orderedlazyset(_orderedsetmixin, |
|
2504 | class orderedlazyset(_orderedsetmixin, filteredset): | |
2505 |
"""Subclass of |
|
2505 | """Subclass of filteredset which subset can be ordered either ascending or | |
2506 | descendingly |
|
2506 | descendingly | |
2507 | """ |
|
2507 | """ | |
2508 | def __init__(self, subset, condition, ascending=True): |
|
2508 | def __init__(self, subset, condition, ascending=True): | |
@@ -2587,7 +2587,7 b' class _addset(_orderedsetmixin):' | |||||
2587 | def filter(self, condition): |
|
2587 | def filter(self, condition): | |
2588 | if self._ascending is not None: |
|
2588 | if self._ascending is not None: | |
2589 | return orderedlazyset(self, condition, ascending=self._ascending) |
|
2589 | return orderedlazyset(self, condition, ascending=self._ascending) | |
2590 |
return |
|
2590 | return filteredset(self, condition) | |
2591 |
|
2591 | |||
2592 | def ascending(self): |
|
2592 | def ascending(self): | |
2593 | if self._ascending is None: |
|
2593 | if self._ascending is None: | |
@@ -2609,13 +2609,13 b' class _addset(_orderedsetmixin):' | |||||
2609 | filterfunc = other.__contains__ |
|
2609 | filterfunc = other.__contains__ | |
2610 | if self._ascending is not None: |
|
2610 | if self._ascending is not None: | |
2611 | return orderedlazyset(self, filterfunc, ascending=self._ascending) |
|
2611 | return orderedlazyset(self, filterfunc, ascending=self._ascending) | |
2612 |
return |
|
2612 | return filteredset(self, filterfunc) | |
2613 |
|
2613 | |||
2614 | def __sub__(self, other): |
|
2614 | def __sub__(self, other): | |
2615 | filterfunc = lambda r: r not in other |
|
2615 | filterfunc = lambda r: r not in other | |
2616 | if self._ascending is not None: |
|
2616 | if self._ascending is not None: | |
2617 | return orderedlazyset(self, filterfunc, ascending=self._ascending) |
|
2617 | return orderedlazyset(self, filterfunc, ascending=self._ascending) | |
2618 |
return |
|
2618 | return filteredset(self, filterfunc) | |
2619 |
|
2619 | |||
2620 | def __add__(self, other): |
|
2620 | def __add__(self, other): | |
2621 | """When both collections are ascending or descending, preserve the order |
|
2621 | """When both collections are ascending or descending, preserve the order |
General Comments 0
You need to be logged in to leave comments.
Login now