Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 24457:c5022f3579b9
revset: add __repr__ to all smartset classes
This is sometimes useful for debugging.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 16 Mar 2015 18:15:06 +0900 |
parents | 582cfcc843c7 |
children | 7d87f672d069 |
comparison
equal
deleted
inserted
replaced
24456:a05c6b400616 | 24457:c5022f3579b9 |
---|---|
2834 return self._asclist[-1] | 2834 return self._asclist[-1] |
2835 else: | 2835 else: |
2836 return self._asclist[0] | 2836 return self._asclist[0] |
2837 return None | 2837 return None |
2838 | 2838 |
2839 def __repr__(self): | |
2840 d = {None: '', False: '-', True: '+'}[self._ascending] | |
2841 return '<%s%s %r>' % (type(self).__name__, d, self._list) | |
2842 | |
2839 class filteredset(abstractsmartset): | 2843 class filteredset(abstractsmartset): |
2840 """Duck type for baseset class which iterates lazily over the revisions in | 2844 """Duck type for baseset class which iterates lazily over the revisions in |
2841 the subset and contains a function which tests for membership in the | 2845 the subset and contains a function which tests for membership in the |
2842 revset | 2846 revset |
2843 """ | 2847 """ |
2917 # slowly consume everything. This needs improvement | 2921 # slowly consume everything. This needs improvement |
2918 it = lambda: reversed(list(self)) | 2922 it = lambda: reversed(list(self)) |
2919 for x in it(): | 2923 for x in it(): |
2920 return x | 2924 return x |
2921 return None | 2925 return None |
2926 | |
2927 def __repr__(self): | |
2928 return '<%s %r>' % (type(self).__name__, self._subset) | |
2922 | 2929 |
2923 class addset(abstractsmartset): | 2930 class addset(abstractsmartset): |
2924 """Represent the addition of two sets | 2931 """Represent the addition of two sets |
2925 | 2932 |
2926 Wrapper structure for lazily adding two structures without losing much | 2933 Wrapper structure for lazily adding two structures without losing much |
3091 self.reverse() | 3098 self.reverse() |
3092 val = self.first() | 3099 val = self.first() |
3093 self.reverse() | 3100 self.reverse() |
3094 return val | 3101 return val |
3095 | 3102 |
3103 def __repr__(self): | |
3104 d = {None: '', False: '-', True: '+'}[self._ascending] | |
3105 return '<%s%s %r, %r>' % (type(self).__name__, d, self._r1, self._r2) | |
3106 | |
3096 class generatorset(abstractsmartset): | 3107 class generatorset(abstractsmartset): |
3097 """Wrap a generator for lazy iteration | 3108 """Wrap a generator for lazy iteration |
3098 | 3109 |
3099 Wrapper structure for generators that provides lazy membership and can | 3110 Wrapper structure for generators that provides lazy membership and can |
3100 be iterated more than once. | 3111 be iterated more than once. |
3260 return self.first() | 3271 return self.first() |
3261 if self: | 3272 if self: |
3262 return it().next() | 3273 return it().next() |
3263 return None | 3274 return None |
3264 | 3275 |
3276 def __repr__(self): | |
3277 d = {False: '-', True: '+'}[self._ascending] | |
3278 return '<%s%s>' % (type(self).__name__, d) | |
3279 | |
3265 class spanset(abstractsmartset): | 3280 class spanset(abstractsmartset): |
3266 """Duck type for baseset class which represents a range of revisions and | 3281 """Duck type for baseset class which represents a range of revisions and |
3267 can work lazily and without having all the range in memory | 3282 can work lazily and without having all the range in memory |
3268 | 3283 |
3269 Note that spanset(x, y) behave almost like xrange(x, y) except for two | 3284 Note that spanset(x, y) behave almost like xrange(x, y) except for two |
3364 it = self.fastasc | 3379 it = self.fastasc |
3365 for x in it(): | 3380 for x in it(): |
3366 return x | 3381 return x |
3367 return None | 3382 return None |
3368 | 3383 |
3384 def __repr__(self): | |
3385 d = {False: '-', True: '+'}[self._ascending] | |
3386 return '<%s%s %d:%d>' % (type(self).__name__, d, | |
3387 self._start, self._end - 1) | |
3388 | |
3369 class fullreposet(spanset): | 3389 class fullreposet(spanset): |
3370 """a set containing all revisions in the repo | 3390 """a set containing all revisions in the repo |
3371 | 3391 |
3372 This class exists to host special optimization and magic to handle virtual | 3392 This class exists to host special optimization and magic to handle virtual |
3373 revisions such as "null". | 3393 revisions such as "null". |