Show More
@@ -372,6 +372,18 b' class baseset(abstractsmartset):' | |||||
372 | def __sub__(self, other): |
|
372 | def __sub__(self, other): | |
373 | return self._fastsetop(other, '__sub__') |
|
373 | return self._fastsetop(other, '__sub__') | |
374 |
|
374 | |||
|
375 | def _slice(self, start, stop): | |||
|
376 | # creating new list should be generally cheaper than iterating items | |||
|
377 | if self._ascending is None: | |||
|
378 | return baseset(self._list[start:stop], istopo=self._istopo) | |||
|
379 | ||||
|
380 | data = self._asclist | |||
|
381 | if not self._ascending: | |||
|
382 | start, stop = max(len(data) - stop, 0), max(len(data) - start, 0) | |||
|
383 | s = baseset(data[start:stop], istopo=self._istopo) | |||
|
384 | s._ascending = self._ascending | |||
|
385 | return s | |||
|
386 | ||||
375 | def __repr__(self): |
|
387 | def __repr__(self): | |
376 | d = {None: '', False: '-', True: '+'}[self._ascending] |
|
388 | d = {None: '', False: '-', True: '+'}[self._ascending] | |
377 | s = _formatsetrepr(self._datarepr) |
|
389 | s = _formatsetrepr(self._datarepr) |
@@ -1037,6 +1037,49 b' Test smartset.slice() by first/last()' | |||||
1037 | 6 |
|
1037 | 6 | |
1038 | 7 |
|
1038 | 7 | |
1039 |
|
1039 | |||
|
1040 | (using baseset) | |||
|
1041 | ||||
|
1042 | $ hg debugrevspec --no-show-revs -s 0+1+2+3+4+5+6+7 | |||
|
1043 | * set: | |||
|
1044 | <baseset [0, 1, 2, 3, 4, 5, 6, 7]> | |||
|
1045 | $ hg debugrevspec --no-show-revs -s 0::7 | |||
|
1046 | * set: | |||
|
1047 | <baseset+ [0, 1, 2, 3, 4, 5, 6, 7]> | |||
|
1048 | $ log 'limit(0+1+2+3+4+5+6+7, 3, 4)' | |||
|
1049 | 4 | |||
|
1050 | 5 | |||
|
1051 | 6 | |||
|
1052 | $ log 'limit(sort(0::7, rev), 3, 4)' | |||
|
1053 | 4 | |||
|
1054 | 5 | |||
|
1055 | 6 | |||
|
1056 | $ log 'limit(sort(0::7, -rev), 3, 4)' | |||
|
1057 | 3 | |||
|
1058 | 2 | |||
|
1059 | 1 | |||
|
1060 | $ log 'last(sort(0::7, rev), 2)' | |||
|
1061 | 6 | |||
|
1062 | 7 | |||
|
1063 | $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 6)' | |||
|
1064 | * set: | |||
|
1065 | <baseset+ [6, 7]> | |||
|
1066 | 6 | |||
|
1067 | 7 | |||
|
1068 | $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 9)' | |||
|
1069 | * set: | |||
|
1070 | <baseset+ []> | |||
|
1071 | $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 6)' | |||
|
1072 | * set: | |||
|
1073 | <baseset- [0, 1]> | |||
|
1074 | 1 | |||
|
1075 | 0 | |||
|
1076 | $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 9)' | |||
|
1077 | * set: | |||
|
1078 | <baseset- []> | |||
|
1079 | $ hg debugrevspec -s 'limit(0::7, 0)' | |||
|
1080 | * set: | |||
|
1081 | <baseset+ []> | |||
|
1082 | ||||
1040 | Test order of first/last revisions |
|
1083 | Test order of first/last revisions | |
1041 |
|
1084 | |||
1042 | $ hg debugrevspec -s 'first(4:0, 3) & 3:' |
|
1085 | $ hg debugrevspec -s 'first(4:0, 3) & 3:' | |
@@ -1967,8 +2010,7 b' ordering defined by it.' | |||||
1967 | define) |
|
2010 | define) | |
1968 | * set: |
|
2011 | * set: | |
1969 | <filteredset |
|
2012 | <filteredset | |
1970 |
<baseset |
|
2013 | <baseset [1]>, | |
1971 | <baseset [1, 0, 2]>>, |
|
|||
1972 | <spanset- 0:3>> |
|
2014 | <spanset- 0:3>> | |
1973 | 1 |
|
2015 | 1 | |
1974 |
|
2016 | |||
@@ -2003,8 +2045,7 b' ordering defined by it.' | |||||
2003 | <filteredset |
|
2045 | <filteredset | |
2004 | <spanset- 0:3>, |
|
2046 | <spanset- 0:3>, | |
2005 | <not |
|
2047 | <not | |
2006 |
<baseset |
|
2048 | <baseset [1]>>> | |
2007 | <baseset [1, 2, 0]>>>> |
|
|||
2008 | 2 |
|
2049 | 2 | |
2009 | 0 |
|
2050 | 0 | |
2010 |
|
2051 | |||
@@ -3628,8 +3669,7 b' issue2549 - correct optimizations' | |||||
3628 | ('symbol', '2'))) |
|
3669 | ('symbol', '2'))) | |
3629 | * set: |
|
3670 | * set: | |
3630 | <filteredset |
|
3671 | <filteredset | |
3631 |
<baseset |
|
3672 | <baseset [1, 2]>, | |
3632 | <baseset [1, 2, 3]>>, |
|
|||
3633 | <not |
|
3673 | <not | |
3634 | <baseset [2]>>> |
|
3674 | <baseset [2]>>> | |
3635 | 1 |
|
3675 | 1 | |
@@ -3683,8 +3723,7 b' issue2549 - correct optimizations' | |||||
3683 | ('symbol', '2'))) |
|
3723 | ('symbol', '2'))) | |
3684 | * set: |
|
3724 | * set: | |
3685 | <filteredset |
|
3725 | <filteredset | |
3686 |
<baseset |
|
3726 | <baseset [2]>, | |
3687 | <baseset [2, 1]>>, |
|
|||
3688 | <not |
|
3727 | <not | |
3689 | <baseset [2]>>> |
|
3728 | <baseset [2]>>> | |
3690 |
|
3729 |
General Comments 0
You need to be logged in to leave comments.
Login now