Commit Graph

322 Commits

Author SHA1 Message Date
Lucas Moscovicz
6f3e54ea87 revset: added documentation and comment for spanset class 2014-03-14 10:59:51 -07:00
Lucas Moscovicz
432476d8c0 revset: changed smartset methods to return ordered addsets
Now when adding two structures that are ordered, they are wrapped into an
_addset and they get added lazily while keeping the order.
2014-03-11 17:25:53 -07:00
Lucas Moscovicz
dd9f8534d9 revset: added isascending and isdescending methods to _addset
This methods are intended to duck-type baseset, so we will still have _addset
as a private class but now we can return it without wrapping it into an
orderedlazyset or a lazyset.

These were the last methods to add for smartset compatibility.
2014-03-14 10:24:09 -07:00
Lucas Moscovicz
c5a9f97171 revset: added __add__ method to _addset
This method is intended to duck-type baseset, so we will still have _addset as a
private class but we will be able to return it without wrapping it into an
orderedlazyset or a lazyset.
2014-03-14 10:23:54 -07:00
Lucas Moscovicz
a79e6ad5a0 revset: added __sub__ mehtod to _addset
This method is intended to duck-type baseset, so we will still have _addset as a
private class but now will be able to return it without wrapping it into an
orderedlazyset or a lazyset.
2014-03-14 10:22:51 -07:00
Lucas Moscovicz
02e069f77d revset: added __and__ method to _addset
This method is intended to duck-type baseset, so we will still have _addset as a
private class but  we will be able to return it without wrapping it into an
orderedlazyset or a lazyset.
2014-03-14 10:22:29 -07:00
Lucas Moscovicz
73a28cdab8 revset: added ascending and descending methods to _addset
This methods are intended to duck-type baseset, so we will still have _addset
as a private class but will be able return it without wrapping it into an
orderedlazyset or a lazyset.
2014-03-14 10:21:56 -07:00
Lucas Moscovicz
e603775f94 revset: added filter method to _addset
This method is intended to duck-type baseset, so we will still have _addset
as a private class but we will be able return it without wrapping it into an
orderedlazyset or a lazyset.
2014-03-13 19:12:36 -07:00
Lucas Moscovicz
8adde22fdb revset: added comments to all methods needed to duck-type from baseset
All this methods are required to duck-type for any class that works as a smart
set.
2014-03-14 09:18:14 -07:00
Lucas Moscovicz
23a1573060 revset: use more explicit argument names for baseset methods
Use other instead of x and condition instead of l
2014-03-14 10:10:18 -07:00
Lucas Moscovicz
1e32ffe0b9 revset: added isascending and isdescending methods to smartset classes
This methods state if the class is sorted in an ascending or descending order

We need this to implement methods based on order on smartset classes in order
to be able to create new objects with a given order.

We cannot just rely on a simple boolean since unordered set are neither
ascending nor descending.
2014-03-11 17:09:23 -07:00
Lucas Moscovicz
8004a27cbf revset: added sort method in addset
We need this method to duck-type generatorset since this class is not going to
be used outside revset.py and we don't need to duck-type baseset.

This sort method will only do something when the addset is not already sorted
or is not sorted in the way we want it to be.
2014-03-11 17:03:43 -07:00
Lucas Moscovicz
62c7bb9117 revset: added reverse method to addset
This method is needed to duck type generatorset.
2014-03-13 18:57:30 -07:00
Lucas Moscovicz
e5f79a44be revset: changed _iterator() method on addset to work with a given order
If the two collections are in ascending order, yield their values in an
ordered way by iterating both at the same time and picking the values to
yield.
2014-03-13 13:29:04 -07:00
Lucas Moscovicz
f2b80f803a revset: changed _iterator() in addset to use the generated list when available
Now when all the elements have been generated, the iterator will just use the
generated list instead of going through all the elements again.
2014-03-13 14:51:04 -07:00
Lucas Moscovicz
1a5e79571b revset: added cached generated list to addset
This way when all the values have been generated the list can be sorted
without having to generate them all again.
2014-03-11 16:59:42 -07:00
Lucas Moscovicz
67d42c8519 revset: changed sort method to use native sort implementation of smartsets
When sort is done by revision or reversed revision number it can just call
sort on the set and doesn't have to iterate it all over again.
2014-03-13 17:15:21 -07:00
Lucas Moscovicz
6da2a5ca22 revset: fixed sorting issue with spanset
When a spanset was being sorted it didn't take into account it's current
state (ascending or descending) and it reversed itself everytime the reverse
parameter was True.

This is not yet used but it will be as soon as the sort revset is changed to
directly use the structures sort method.
2014-03-13 17:16:58 -07:00
Lucas Moscovicz
edbf51ad8f revset: added __nonzero__ method to spanset class
Implemented it in a lazy way, just look for the first non-filtered revision
and return True if there's any revision at all.
2014-03-14 09:07:59 -07:00
Lucas Moscovicz
04e9ab0a9b revset: optimized sort method in lazyset class
We are taking advantage of the smartset classes sort method when it exists and
converting the set to a baseset otherwise.
2014-03-06 09:41:47 -08:00
Durham Goode
f906635299 revset: improve head revset performance
Previously the head() revset would iterate over every item in the subset and
check if it was a head.  Since the subset is often the entire repo, this was
slow on large repos. Now we iterate over each item in the head list and check if
it's in the subset, which results in much less work.

hg log -r 'head()' on a large repo:
Before: 0.95s
After: 0.28s
2014-03-13 13:47:21 -07:00
Lucas Moscovicz
36702af6f9 revset: added ascending attribute to addset class
In case both collections are in an ascending/descending order then we will be
able to iterate them lazily while keeping the order.
2014-03-11 16:52:15 -07:00
Lucas Moscovicz
7da57d658a revset: added set method to addset to duck type generatorset
Since this class is only going to be used inside revset.py (it does not duck
type baseset) it needs to duck type only a few more methods for the next
patches.
2014-03-10 10:49:04 -07:00
Matt Mackall
064d711c69 revsets: backout f497f83593d8 due to performance regressions 2014-03-13 14:34:32 -05:00
Lucas Moscovicz
efb319fb76 revset: made addset a private class
This class is not supposed to be used outside revset.py since it only
wraps content that is used by baseset typed classes.

It only gets created by revset operations or private methods.
2014-03-12 17:20:26 -07:00
Lucas Moscovicz
a50567190d revset: made descgeneratorset a private class
This class is not supposed to be used outside revset.py since it only
wraps content that is used by baseset typed classes.

It only gets created by revset operations or private methods.
2014-03-12 17:19:46 -07:00
Lucas Moscovicz
e6b1cc49b9 revset: made ascgeneratorset a private class
This class is not supposed to be used outside revset.py since it only
wraps content that is used by baseset typed classes.

It only gets created by revset operations or private methods.
2014-03-12 17:18:54 -07:00
Lucas Moscovicz
7e33d4c691 revset: made generatorset a private class
This class are not supposed to be used outside revset.py since it only
wraps content that is used by baseset typed classes.

It only gets created by revset operations or private methods.
2014-03-12 17:07:38 -07:00
Lucas Moscovicz
2c2b32444e revset: added sort methods to generatorsets
Method needed to propagate sort calls amongst lazy structures.
The generated list (stored in the object) is sorted.

If the generated list did not contain all elements from the generator, we
take care of that before sorting the list.
2014-02-24 16:36:17 -08:00
Lucas Moscovicz
9db776218f revset: changed __add__ methods on lazy sets to return addsets (issue4191)
Performance Benchmarking:

$ hg --time log --graph --style compact --limit 6 -r 'sort((::. or bookmark()
or heads(public())), "-rev")'
time: real 1.540 secs (user 1.510+0.000 sys 0.020+0.000)

$ ./hg --time log --graph --style compact --limit 6 -r 'sort((::. or
bookmark() or heads(public())), "-rev")'
time: real 1.240 secs (user 1.190+0.000 sys 0.040+0.010)
2014-03-07 14:06:49 -08:00
Lucas Moscovicz
82e3bb4e2c revset: added addset class with its basic methods
This class addresses the problem of losing performance on the __contains__
method when adding two smart structures with fast membership testing.
2014-03-07 13:48:31 -08:00
Lucas Moscovicz
a47624e9b5 revset: changed _children method to use lazy structures 2014-02-11 14:03:43 -08:00
Lucas Moscovicz
c7b531ba29 revset: changed descendants revset to use lazy generators
Performance Benchmarking:

$ time hg log -qr "0:: and 0:5"
...

real  0m3.665s
user  0m3.364s
sys 0m0.289s

$ time ./hg log -qr "0:: and 0:5"
...

real  0m0.492s
user  0m0.394s
sys 0m0.097s
2014-02-10 12:26:45 -08:00
Lucas Moscovicz
ead9ef7efc revset: optimized _revancestors method based on order of revisions
If the revisions for which the ancestors are required are in descending order,
it lazily loads them into a heap to be able to yield values faster.
2014-02-07 13:44:57 -08:00
Lucas Moscovicz
8456e8d71a revset: changed ancestors revset to return lazy generators
This will not improve revsets like "::tip" but will do when that gets
intersected or substracted with another revset.

Performance Benchmarking:

$ time hg log -qr "draft() and ::tip"
...

real  0m3.961s
user  0m3.640s
sys 0m0.313s

$ time ./hg log -qr "draft() and ::tip"
...

real  0m1.080s
user  0m0.987s
sys 0m0.083s
2014-02-07 10:32:02 -08:00
Lucas Moscovicz
4a4c0782a7 revset: changed methods in spanset to return ordered sets
Now __sub__ and __and__ can smartly return ordered lazysets.
2014-02-18 13:07:08 -08:00
Lucas Moscovicz
82070b57ca revset: added sort method to orderedlazyset 2014-02-25 10:36:23 -08:00
Lucas Moscovicz
9ade74466e revset: added order methods to lazyset classes
This will allow revsets to ask for an ordered set when possible to be able to
work lazily with it.
2014-02-07 08:44:18 -08:00
Lucas Moscovicz
e87d3ac6ae revset: added ordered generatorset classes with __contains__ method
They stop iterating as soon as they go past the value they are looking for,
so, for values not in the generator they return faster.
2014-02-27 17:27:03 -08:00
Lucas Moscovicz
d710c5103e revset: changed generatorset code to remove unnecesary function call
Removed _nextitem() method, now __iter__ has that logic and __contains__ uses
__iter__ to check for membership.
2014-03-03 12:54:46 -08:00
Durham Goode
f2e7078d1a revset: add 'only' revset
Adds a only() revset that has two forms:

only(<set>) is equivalent to "::<set> - ::(heads() - heads(<set>::))"

only(<include>,<exclude>) is equivalent to "::<include> - ::<exclude>"

On a large repo, this implementation can process/traverse 50,000 revs in 0.7
seconds, versus 4.2 seconds using "::<include> - ::<exclude>".

This is useful for performing histedits on your branch:
hg histedit -r 'first(only(.))'

Or lifting branch foo off of branch bar:
hg rebase -d @ -s 'only(foo, bar)'

Or a variety of other uses.
2013-11-16 08:57:08 -08:00
Lucas Moscovicz
fbd41fa2f4 revset: added basic operators to orderedlazyset
Now __and__ and __sub__ return orderedlazyset.
2014-02-06 17:42:08 -08:00
Lucas Moscovicz
66c7004b8c revset: changed revset code to use filter method
Revset methods now use the filter code to apply a condition.
2014-02-06 09:28:41 -08:00
Lucas Moscovicz
e70d62798f revset: added filter method to revset classes
This method will replace the creation of lazysets inside the revset methods.
Instead, the classes that handle lazy structures will create them based on
their current order.
2014-02-06 17:18:11 -08:00
Lucas Moscovicz
2e8fa99be8 revset: added orderedlazyset class 2014-02-05 15:24:08 -08:00
Lucas Moscovicz
5d74d40ff4 revset: changed spanset __add__ implementation to work lazily
$ time hg log -qr "first(0:tip or draft())"
...

real  0m1.032s
user  0m0.841s
sys 0m0.179s

$ time ./hg log -qr "first(0:tip or draft())"
...

real  0m0.378s
user  0m0.291s
sys 0m0.085s
2014-02-13 09:18:16 -08:00
Lucas Moscovicz
3c92337f5c revset: changed lazyset __add__ implementation to work lazily
Performance Benchmarking:

$ time hg log -qr "first(author(mpm) or branch(default))"
0:3a6a38229d41

real  0m3.875s
user  0m3.818s
sys 0m0.051s

$ time ./hg log -qr "first(author(mpm) or branch(default))"
0:3a6a38229d41

real  0m0.213s
user  0m0.174s
sys 0m0.038s
2014-02-13 09:00:25 -08:00
Lucas Moscovicz
df2d5bd9ed revset: added _hexlist method to replace _list for %ln
Now %ln expression goes through _hexlist and doesn't do any unnecesary
processing anymore.
2014-02-26 17:15:55 -08:00
Lucas Moscovicz
d6c47fdc4c revset: added _intlist method to replace _list for %ld
Now %ld expression goes through _intlist and doesn't do any unnecesary
processing anymore.
2014-02-26 12:36:36 -08:00
Lucas Moscovicz
59ef037f26 revset: added __nonzero__ method to lazyset
Now it doesn't have to go through all the set and can return lazily as soon as
it finds one element.
2014-02-20 10:15:38 -08:00