Commit Graph

470 Commits

Author SHA1 Message Date
Pierre-Yves David
98513b6f74 generatorset: implement first and last methods 2014-10-06 12:52:36 -07:00
Pierre-Yves David
0a7da549e2 addset: implement first and last methods
The implementation is non-lazy for now. One may want to make it more lazy in the
future.
2014-10-06 11:57:59 -07:00
Pierre-Yves David
0567fe01bf spanset: implement first and last methods 2014-10-06 11:54:53 -07:00
Pierre-Yves David
798e6b00b0 smartset: add first and last methods
In multiple places in the code, we use `someset[0]` or `someset[-1]`. This
works only because the `someset` is usually a baseset. For the same reason we
introduce a `first` and `last` methods to be implemented for all smartset
classes.
2014-10-06 11:46:53 -07:00
Pierre-Yves David
a814455e99 revset-last: remove user of baseset.append
A `baseset` has multiple cached results and will get even more in the future.
Making it an object "populated once" like the other smartsets makes it both safer
and simpler. The append method will be removed at some point.
2014-10-08 00:55:09 -07:00
Pierre-Yves David
e7663a53cd revset-limit: remove user of baseset.append
A `baseset` has multiple cached results and will get even more in the future.
Making it an object "populated once" like the other smartsets makes it both safer
and simpler. The append method will be removed at some point.
2014-10-06 10:57:01 -07:00
Pierre-Yves David
9f5274f4bc baseset: use default value instead of [] when possible
For pure cleanup purposes, we replace all the occurences of `baseset([])` with
`baseset()`.
2014-10-06 10:41:43 -07:00
Pierre-Yves David
a046529f73 generatorset: implement isascending and isdescending 2014-10-04 06:17:18 -07:00
Pierre-Yves David
d4b459bd9f generatorset: explicitly track iteration order
The expected iteration order may be different than the fast iteration order (eg:
ancestors(42) is expected to be iterated upward but is fast/lazy to compute
downward.

So we explicitly track the iteration order and enforce it if the manual
iteration is requested.

Default expected iteration order of a generator set is ascending because I'm
not aware of any descending revset that need a generatorset. The first to find
such descending revset will have the pleasure to make this configurable.
2014-10-03 21:11:56 -07:00
Pierre-Yves David
a82beab10d addset: drop caching through generatorset
The utility of this cache is debatable (no visible benchmark impact) and using
generatorset for such purpose makes the code complicated.

We drop it for now. Someone can reintroduce a smart version of it in the future
if it is detected to be relevant.
2014-10-03 20:23:02 -07:00
Pierre-Yves David
e6831448a3 generatorset: get list-based fast iterations after the generator is consumed
When all revisions are known, we shortcut most of the class logic to use list
iteration instead. The cost of the sort is expected to be non-significant. The
list creation and sorting could be done lazily in the future. We have to copy
the list to not break existing iterator created before we finished consuming the
generator.
2014-10-03 21:01:30 -07:00
Pierre-Yves David
1d2cf353fc generatorset: move iteration code into _iterator
_iterator handles the generator iteration. The `__iter__` method will need
changes to handle ordering-related information.
2014-10-03 20:48:28 -07:00
Pierre-Yves David
a0f1c697e2 generatorset: stop using a base as the _genlist
It does not add anything and makes it more complicated to have a simple baseset
implementation.
2014-10-03 20:43:48 -07:00
Pierre-Yves David
9d3c052ee3 generatorset: drop the leading underscore in the class name
This is a real smart set now.
2014-10-03 20:12:02 -07:00
Pierre-Yves David
dc2b8470bf generatorset: update the docstring now that it is a smartset
The documentation was still stating that this class was not a smartset. We drop
that part.
2014-10-03 20:14:43 -07:00
Pierre-Yves David
ccc0b916ad addset: drop the leading underscore from the class name
This class is now a real smartset.
2014-10-03 20:18:48 -07:00
Pierre-Yves David
e434af74be addset: this is a smartset, update the docstring
The documentation was still stating that this class is a not a smartset. We drop
that part.
2014-10-03 20:17:12 -07:00
Pierre-Yves David
d1e22facbe addset: use the ascending argument in _iterordered
Fix a bug where fastasc and fastdesc were iterator in the same order as
self._ascending.
2014-10-09 05:27:23 -07:00
Pierre-Yves David
cc531eaf7c revset: remove the now unused _descgeneratorset class 2014-10-03 12:54:56 -05:00
Pierre-Yves David
5660381e46 revset: use _generatorset in _revancestors
The _descgeneratorset class is going away.
2014-10-03 12:53:41 -05:00
Pierre-Yves David
0064df5af6 revset: remove now unused class _ascgeneratorset 2014-10-03 12:52:49 -05:00
Pierre-Yves David
2c0f15affd revset: use _generatorset directly in _revdescendant
_ascgeneratorset is going away.
2014-10-03 12:52:17 -05:00
Pierre-Yves David
d8ee591ede generatorset: move membership testing on ordered gen to the main class
We are phasing out the ordered version of the class to simplify the code.
2014-10-03 12:46:34 -05:00
Pierre-Yves David
f6fa8eb009 generatorset: make use of the new mechanism in the subclass
Until we remove them, we use the new parameter of _generatorset to make sure
the code is run.
2014-10-03 12:36:57 -05:00
Pierre-Yves David
8182bcd552 generatorset: make it possible to use gen as fastasc or fastdesc
We gain a parameter to inform that the generator is ascending or descending. If
the generator is ordered, it is also used for the `fastasc` or `fastdesc`
version.

The _ascgeneratorset and _descgeneratorset class will be removed soon.
2014-10-03 12:36:08 -05:00
Pierre-Yves David
360df469a0 baseset: rely on the abstractsmartset implementation for filter 2014-10-03 03:19:00 -05:00
Pierre-Yves David
1173000a7c _orderedsetmixin: drop this now unused class
All my friends are dead.
2014-10-02 19:48:14 -05:00
Pierre-Yves David
214e70e3ed spanset: drop _orderedsetmixin inheritance
The min/max method are as well provided by abstractsmartset.
2014-10-02 19:47:33 -05:00
Pierre-Yves David
5c0b91dc51 orderedlazyset: drop this now unused class
All my friends are dead.
2014-10-03 01:44:52 -05:00
Pierre-Yves David
2d5a7f7706 _descendant: use filteredset instead of orderedlazyset
The orderedlazyset class is going away. Filteredset gives the same service.
2014-10-02 19:43:42 -05:00
Pierre-Yves David
5081443516 addset: use the base implementation for ascending and descending 2014-10-03 01:37:13 -05:00
Pierre-Yves David
c77388089d addset: use base implementation for __filter__ 2014-10-03 01:34:25 -05:00
Pierre-Yves David
02ce29364d addset: use base implementation for __add__ 2014-10-03 01:33:32 -05:00
Pierre-Yves David
355c9d986e addset: use base implementation for __sub__ 2014-10-03 01:32:50 -05:00
Pierre-Yves David
a24bd6fb5b addset: use base implementation for __and__ 2014-10-03 01:31:46 -05:00
Pierre-Yves David
c65b8b42bd addset: promote to real smartset
Better revset performance are also achieved with less overlay. There is no good
reason for addset to not be a smartset. We can replace the `_orderedsetmixin`
inheritance since `abstractsmartset` has efficient min and max too.
2014-10-02 19:42:06 -05:00
Pierre-Yves David
7a25a7121b addset: add a __nonzero__ method
This is required to be a full smartset (not sure what was happening before
that...)
2014-10-03 00:12:22 -05:00
Pierre-Yves David
6a1c6ffa59 addset: offer a fastasc and fastdesc methods
If the underlying object offers fast iterators, we use them to provide fast
iterators too.
2014-10-02 23:38:30 -05:00
Pierre-Yves David
89b6f70699 addset: split simple and ordered iteration
We have two goals here. First, we would like to restore the former iteration
order we had in 2.9. Second, we want this logic to be reusable for `fastasc`
and `fastdesc` methods.
2014-10-02 23:28:18 -05:00
Pierre-Yves David
5559000069 generatorset: promote to smartset
This is not going to be efficient but we need all basic set classes to be smartsets
for the other classes to work.
2014-10-03 01:55:09 -05:00
Pierre-Yves David
58b382b0f7 generatorset: implement __nonzero__
This is necessary to become a real smartset.
2014-10-03 01:56:57 -05:00
Pierre-Yves David
a14781af28 spanset: use base implementation for __add__ 2014-10-03 00:31:33 -05:00
Pierre-Yves David
215016c505 spanset: use base implementation for __sub__ 2014-10-03 00:31:18 -05:00
Pierre-Yves David
8f595a844a spanset: use base implementation for __and__ 2014-10-03 00:30:58 -05:00
Pierre-Yves David
12baf0e606 spanset: use base implementation for filter 2014-10-03 00:39:57 -05:00
Pierre-Yves David
5d23f77ec3 filteredset: use base implementation for filter 2014-10-03 01:27:00 -05:00
Pierre-Yves David
1be20553d2 filteredset: use base implementation for __add__ 2014-10-03 01:25:35 -05:00
Pierre-Yves David
23bcf240b5 filteredset: use base implementation for __sub__ 2014-10-03 01:24:30 -05:00
Pierre-Yves David
24ee9a4abf filteredset: use base implementation for __and__ 2014-10-03 01:23:12 -05:00
Pierre-Yves David
13924bc45b abstractsmartset: add default implementation for __sub__ 2014-10-02 19:22:17 -05:00