Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20484:0f1ef9e9e904
revset: added operations to spanset to duck type baseset
Added more operations which are not lazy but only used so far to duck type
baseset.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Thu, 06 Feb 2014 15:56:25 -0800 |
parents | ed57358398af |
children | fb2df4506c87 |
comparison
equal
deleted
inserted
replaced
20483:ed57358398af | 20484:0f1ef9e9e904 |
---|---|
2157 | 2157 |
2158 def __add__(self, x): | 2158 def __add__(self, x): |
2159 l = baseset(self) | 2159 l = baseset(self) |
2160 return l + baseset(x) | 2160 return l + baseset(x) |
2161 | 2161 |
2162 def __len__(self): | |
2163 return abs(self._end - self._start) | |
2164 | |
2165 def __getitem__(self, x): | |
2166 # Basic implementation to be changed in future patches. | |
2167 l = baseset([r for r in self]) | |
2168 return l[x] | |
2169 | |
2170 def sort(self, reverse=False): | |
2171 # Basic implementation to be changed in future patches. | |
2172 if reverse: | |
2173 self.reverse() | |
2174 | |
2175 def reverse(self): | |
2176 if self._start <= self._end: | |
2177 self._start, self._end = self._end - 1, self._start - 1 | |
2178 else: | |
2179 self._start, self._end = self._end + 1, self._start + 1 | |
2180 | |
2181 def set(self): | |
2182 return self | |
2183 | |
2162 # tell hggettext to extract docstrings from these functions: | 2184 # tell hggettext to extract docstrings from these functions: |
2163 i18nfunctions = symbols.values() | 2185 i18nfunctions = symbols.values() |