changeset 22509:fbae659543cf

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 18 Sep 2014 13:04:02 -0700
parents 2434c68d82a8
children 911f5a6579d1
files mercurial/revset.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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.