Show More
@@ -2299,12 +2299,7 class abstractsmartset(object): | |||
|
2299 | 2299 | boolean. |
|
2300 | 2300 | |
|
2301 | 2301 | This is part of the mandatory API for smartset.""" |
|
2302 | kwargs = {} | |
|
2303 | if self.isascending(): | |
|
2304 | kwargs['ascending'] = True | |
|
2305 | elif self.isdescending(): | |
|
2306 | kwargs['ascending'] = False | |
|
2307 | return filteredset(self, condition, **kwargs) | |
|
2302 | return filteredset(self, condition) | |
|
2308 | 2303 | |
|
2309 | 2304 | class baseset(abstractsmartset): |
|
2310 | 2305 | """Basic data structure that represents a revset and contains the basic |
@@ -2406,7 +2401,7 class filteredset(abstractsmartset): | |||
|
2406 | 2401 | the subset and contains a function which tests for membership in the |
|
2407 | 2402 | revset |
|
2408 | 2403 | """ |
|
2409 |
def __init__(self, subset, condition=lambda x: True |
|
|
2404 | def __init__(self, subset, condition=lambda x: True): | |
|
2410 | 2405 | """ |
|
2411 | 2406 | condition: a function that decide whether a revision in the subset |
|
2412 | 2407 | belongs to the revset or not. |
@@ -2414,9 +2409,6 class filteredset(abstractsmartset): | |||
|
2414 | 2409 | self._subset = subset |
|
2415 | 2410 | self._condition = condition |
|
2416 | 2411 | self._cache = {} |
|
2417 | if ascending is not None: | |
|
2418 | ascending = bool(ascending) | |
|
2419 | self._ascending = ascending | |
|
2420 | 2412 | |
|
2421 | 2413 | def __contains__(self, x): |
|
2422 | 2414 | c = self._cache |
@@ -2464,27 +2456,19 class filteredset(abstractsmartset): | |||
|
2464 | 2456 | return l[x] |
|
2465 | 2457 | |
|
2466 | 2458 | def sort(self, reverse=False): |
|
2467 | if self._ascending is None: | |
|
2468 | if not util.safehasattr(self._subset, 'sort'): | |
|
2469 | self._subset = baseset(self._subset) | |
|
2470 | self._subset.sort(reverse=reverse) | |
|
2471 | self._ascending = not reverse | |
|
2472 | elif bool(reverse) == self._ascending: | |
|
2473 | self.reverse() | |
|
2459 | self._subset.sort(reverse=reverse) | |
|
2474 | 2460 | |
|
2475 | 2461 | def reverse(self): |
|
2476 | 2462 | self._subset.reverse() |
|
2477 | if self._ascending is not None: | |
|
2478 | self._ascending = not self._ascending | |
|
2479 | 2463 | |
|
2480 | 2464 | def set(self): |
|
2481 | 2465 | return set([r for r in self]) |
|
2482 | 2466 | |
|
2483 | 2467 | def isascending(self): |
|
2484 | return self._ascending is not None and self._ascending | |
|
2468 | return self._subset.isascending() | |
|
2485 | 2469 | |
|
2486 | 2470 | def isdescending(self): |
|
2487 | return self._ascending is not None and not self._ascending | |
|
2471 | return self._subset.isdescending() | |
|
2488 | 2472 | |
|
2489 | 2473 | def first(self): |
|
2490 | 2474 | for x in self: |
@@ -2493,11 +2477,10 class filteredset(abstractsmartset): | |||
|
2493 | 2477 | |
|
2494 | 2478 | def last(self): |
|
2495 | 2479 | it = None |
|
2496 |
if self._ascending |
|
|
2497 |
i |
|
|
2498 | it = self.fastdesc | |
|
2499 |
|
|
|
2500 | it = self.fastasc | |
|
2480 | if self._subset.isascending: | |
|
2481 | it = self.fastdesc | |
|
2482 | elif self._subset.isdescending: | |
|
2483 | it = self.fastdesc | |
|
2501 | 2484 | if it is None: |
|
2502 | 2485 | # slowly consume everything. This needs improvement |
|
2503 | 2486 | it = lambda: reversed(list(self)) |
General Comments 0
You need to be logged in to leave comments.
Login now