revset: turn spanset into a factory function
We rename the `spanset` class to `_spanset`. `spanset` is now a function that
builds either a `fullreposet` or a `_spanset` according to the argument passed.
At some point, we may force people to explicitly use the `fullreposet`
constructor, but the current approach makes it easier to ensure we use the new
class whenever possible and focus on the benefits of this class.
--- a/mercurial/revset.py Tue Apr 29 19:06:15 2014 -0700
+++ b/mercurial/revset.py Thu Sep 18 13:04:02 2014 -0700
@@ -2732,7 +2732,18 @@
self._cache[x] = False
return False
-class spanset(_orderedsetmixin):
+def spanset(repo, start=None, end=None):
+ """factory function to dispatch between fullreposet and actual spanset
+
+ Feel free to update all spanset call sites and kill this function at some
+ point.
+ """
+ if start is None and end is None:
+ return fullreposet(repo)
+ return _spanset(repo, start, end)
+
+
+class _spanset(_orderedsetmixin):
"""Duck type for baseset class which represents a range of revisions and
can work lazily and without having all the range in memory
@@ -2851,7 +2862,7 @@
def filter(self, l):
return orderedlazyset(self, l, ascending=self.isascending())
-class fullreposet(spanset):
+class fullreposet(_spanset):
"""a set containing all revisions in the repo
This class exists to host special optimisation.