Patchwork [2,of,3] revset: turn spanset into a factory function

mail settings
Submitter Pierre-Yves David
Date Sept. 20, 2014, 12:07 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/5893/
State Superseded
Commit fbae659543cf7c2c87c7c403477dfbc48b819879
Headers show


Pierre-Yves David - Sept. 20, 2014, 12:07 a.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1411070642 25200
#      Thu Sep 18 13:04:02 2014 -0700
# Node ID 5aec2be794fbd94adc4f624c57cdd2fc9907e6e3
# Parent  9daf8851618b46b112314848bd639dadf6ca7381
revset: turn spanset into a factory function

We rename the `spanset` class to `_spanset`. `spanset` is now a function that
build 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 make is easier to ensure we use the new
class whenever possible and focus on the benefit of this class.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -2726,11 +2726,22 @@  class _descgeneratorset(_generatorset):
         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 will to update all spanset call site 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
     Note that spanset(x, y) behave almost like xrange(x, y) except for two
     notable points:
@@ -2845,11 +2856,11 @@  class spanset(_orderedsetmixin):
         return self._start >= self._end
     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.