##// END OF EJS Templates
smartset: extract spanset factory to make it constructed without a repo...
Yuya Nishihara -
r32818:9ddb18ae default
parent child Browse files
Show More
@@ -906,7 +906,22 b' class generatorset(abstractsmartset):'
906 906 d = {False: '-', True: '+'}[self._ascending]
907 907 return '<%s%s>' % (type(self).__name__, d)
908 908
909 class spanset(abstractsmartset):
909 def spanset(repo, start=0, end=None):
910 """Create a spanset that represents a range of repository revisions
911
912 start: first revision included the set (default to 0)
913 end: first revision excluded (last+1) (default to len(repo))
914
915 Spanset will be descending if `end` < `start`.
916 """
917 if end is None:
918 end = len(repo)
919 ascending = start <= end
920 if not ascending:
921 start, end = end + 1, start + 1
922 return _spanset(start, end, ascending, repo.changelog.filteredrevs)
923
924 class _spanset(abstractsmartset):
910 925 """Duck type for baseset class which represents a range of revisions and
911 926 can work lazily and without having all the range in memory
912 927
@@ -916,23 +931,11 b' class spanset(abstractsmartset):'
916 931 - revision filtered with this repoview will be skipped.
917 932
918 933 """
919 def __init__(self, repo, start=0, end=None):
920 """
921 start: first revision included the set
922 (default to 0)
923 end: first revision excluded (last+1)
924 (default to len(repo)
925
926 Spanset will be descending if `end` < `start`.
927 """
928 if end is None:
929 end = len(repo)
930 self._ascending = start <= end
931 if not self._ascending:
932 start, end = end + 1, start +1
934 def __init__(self, start, end, ascending, hiddenrevs):
933 935 self._start = start
934 936 self._end = end
935 self._hiddenrevs = repo.changelog.filteredrevs
937 self._ascending = ascending
938 self._hiddenrevs = hiddenrevs
936 939
937 940 def sort(self, reverse=False):
938 941 self._ascending = not reverse
@@ -1020,10 +1023,10 b' class spanset(abstractsmartset):'
1020 1023
1021 1024 def __repr__(self):
1022 1025 d = {False: '-', True: '+'}[self._ascending]
1023 return '<%s%s %d:%d>' % (type(self).__name__, d,
1026 return '<%s%s %d:%d>' % (type(self).__name__.lstrip('_'), d,
1024 1027 self._start, self._end)
1025 1028
1026 class fullreposet(spanset):
1029 class fullreposet(_spanset):
1027 1030 """a set containing all revisions in the repo
1028 1031
1029 1032 This class exists to host special optimization and magic to handle virtual
@@ -1031,7 +1034,8 b' class fullreposet(spanset):'
1031 1034 """
1032 1035
1033 1036 def __init__(self, repo):
1034 super(fullreposet, self).__init__(repo)
1037 super(fullreposet, self).__init__(0, len(repo), True,
1038 repo.changelog.filteredrevs)
1035 1039
1036 1040 def __and__(self, other):
1037 1041 """As self contains the whole repo, all of the other set should also be
General Comments 0
You need to be logged in to leave comments. Login now