Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20737:b141080e70c5
revset: added documentation and comment for spanset class
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Fri, 14 Mar 2014 10:59:51 -0700 |
parents | 4d27c30d58d5 |
children | 33943add5d65 |
comparison
equal
deleted
inserted
replaced
20736:b0203624ab20 | 20737:b141080e70c5 |
---|---|
2638 return False | 2638 return False |
2639 | 2639 |
2640 class spanset(object): | 2640 class spanset(object): |
2641 """Duck type for baseset class which represents a range of revisions and | 2641 """Duck type for baseset class which represents a range of revisions and |
2642 can work lazily and without having all the range in memory | 2642 can work lazily and without having all the range in memory |
2643 | |
2644 Note that spanset(x, y) behave almost like xrange(x, y) except for two | |
2645 notable points: | |
2646 - when x < y it will be automatically descending, | |
2647 - revision filtered with this repoview will be skipped. | |
2648 | |
2643 """ | 2649 """ |
2644 def __init__(self, repo, start=0, end=None): | 2650 def __init__(self, repo, start=0, end=None): |
2651 """ | |
2652 start: first revision included the set | |
2653 (default to 0) | |
2654 end: first revision excluded (last+1) | |
2655 (default to len(repo) | |
2656 | |
2657 Spanset will be descending if `end` < `start`. | |
2658 """ | |
2645 self._start = start | 2659 self._start = start |
2646 if end is not None: | 2660 if end is not None: |
2647 self._end = end | 2661 self._end = end |
2648 else: | 2662 else: |
2649 self._end = len(repo) | 2663 self._end = len(repo) |
2727 def sort(self, reverse=False): | 2741 def sort(self, reverse=False): |
2728 if bool(reverse) != (self._start > self._end): | 2742 if bool(reverse) != (self._start > self._end): |
2729 self.reverse() | 2743 self.reverse() |
2730 | 2744 |
2731 def reverse(self): | 2745 def reverse(self): |
2746 # Just switch the _start and _end parameters | |
2732 if self._start <= self._end: | 2747 if self._start <= self._end: |
2733 self._start, self._end = self._end - 1, self._start - 1 | 2748 self._start, self._end = self._end - 1, self._start - 1 |
2734 else: | 2749 else: |
2735 self._start, self._end = self._end + 1, self._start + 1 | 2750 self._start, self._end = self._end + 1, self._start + 1 |
2736 | 2751 |