I uncovered a cycle manifesting in a memory leak by running
hgperfrevset '::tip'. The cycle was due to generatorset.init
assigning a bound method to self.contains. Internet sleuthing
revealed that assigning a bound method to an instance attribute
always creates a cycle.
This commit creates two new variants of generatorset for the special
cases of ascending and descending generators. The special
implementations of contains have been extracted to these classes
where they are defined as contains.
generatorset now implements new and changes the spawned type to
one of the new classes if needed.
@staticmethod could be a simpler way to break cycles.