comparison mercurial/revset.py @ 22753:16c20403de80

_orderedsetmixin: drop this now unused class All my friends are dead.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 02 Oct 2014 19:48:14 -0500
parents 7bbc35c43bff
children 1119e544cd2d
comparison
equal deleted inserted replaced
22752:7bbc35c43bff 22753:16c20403de80
2382 boolean. 2382 boolean.
2383 2383
2384 This is part of the mandatory API for smartset.""" 2384 This is part of the mandatory API for smartset."""
2385 return filteredset(self, condition) 2385 return filteredset(self, condition)
2386 2386
2387 class _orderedsetmixin(object):
2388 """Mixin class with utility methods for smartsets
2389
2390 This should be extended by smartsets which have the isascending(),
2391 isdescending() and reverse() methods"""
2392
2393 def _first(self):
2394 """return the first revision in the set"""
2395 for r in self:
2396 return r
2397 raise ValueError('arg is an empty sequence')
2398
2399 def _last(self):
2400 """return the last revision in the set"""
2401 self.reverse()
2402 m = self._first()
2403 self.reverse()
2404 return m
2405
2406 def min(self):
2407 """return the smallest element in the set"""
2408 if self.isascending():
2409 return self._first()
2410 return self._last()
2411
2412 def max(self):
2413 """return the largest element in the set"""
2414 if self.isascending():
2415 return self._last()
2416 return self._first()
2417
2418 class filteredset(abstractsmartset): 2387 class filteredset(abstractsmartset):
2419 """Duck type for baseset class which iterates lazily over the revisions in 2388 """Duck type for baseset class which iterates lazily over the revisions in
2420 the subset and contains a function which tests for membership in the 2389 the subset and contains a function which tests for membership in the
2421 revset 2390 revset
2422 """ 2391 """