comparison mercurial/revset.py @ 22809:88dad916c008

spanset: implement `first` and `last` methods
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 06 Oct 2014 11:54:53 -0700
parents 228b0aafb1ce
children 7f97cb12782f
comparison
equal deleted inserted replaced
22808:228b0aafb1ce 22809:88dad916c008
2860 return self._start <= self._end 2860 return self._start <= self._end
2861 2861
2862 def isdescending(self): 2862 def isdescending(self):
2863 return self._start >= self._end 2863 return self._start >= self._end
2864 2864
2865 def first(self):
2866 if self._ascending:
2867 it = self.fastasc
2868 else:
2869 it = self.fastdesc
2870 for x in it():
2871 return x
2872 return None
2873
2874 def last(self):
2875 if self._ascending:
2876 it = self.fastdesc
2877 else:
2878 it = self.fastasc
2879 for x in it():
2880 return x
2881 return None
2882
2865 class fullreposet(_spanset): 2883 class fullreposet(_spanset):
2866 """a set containing all revisions in the repo 2884 """a set containing all revisions in the repo
2867 2885
2868 This class exists to host special optimisation. 2886 This class exists to host special optimisation.
2869 """ 2887 """