Mercurial > hg
comparison mercurial/revset.py @ 20659:4f68acdb22ff
revset: changed methods in spanset to return ordered sets
Now __sub__ and __and__ can smartly return ordered lazysets.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Tue, 18 Feb 2014 13:07:08 -0800 |
parents | d7e96dd8e995 |
children | 13c0327eeb6f |
comparison
equal
deleted
inserted
replaced
20658:d7e96dd8e995 | 20659:4f68acdb22ff |
---|---|
2407 self._hiddenrevs) | 2407 self._hiddenrevs) |
2408 | 2408 |
2409 def __and__(self, x): | 2409 def __and__(self, x): |
2410 if isinstance(x, baseset): | 2410 if isinstance(x, baseset): |
2411 x = x.set() | 2411 x = x.set() |
2412 return lazyset(self, lambda r: r in x) | 2412 if self._start <= self._end: |
2413 return orderedlazyset(self, lambda r: r in x) | |
2414 else: | |
2415 return orderedlazyset(self, lambda r: r in x, ascending=False) | |
2413 | 2416 |
2414 def __sub__(self, x): | 2417 def __sub__(self, x): |
2415 if isinstance(x, baseset): | 2418 if isinstance(x, baseset): |
2416 x = x.set() | 2419 x = x.set() |
2417 return lazyset(self, lambda r: r not in x) | 2420 if self._start <= self._end: |
2421 return orderedlazyset(self, lambda r: r not in x) | |
2422 else: | |
2423 return orderedlazyset(self, lambda r: r not in x, ascending=False) | |
2418 | 2424 |
2419 def __add__(self, x): | 2425 def __add__(self, x): |
2420 def iterates(): | 2426 def iterates(): |
2421 for r in self: | 2427 for r in self: |
2422 yield r | 2428 yield r |