revset: add __repr__ to all smartset classes
This is sometimes useful for debugging.
--- a/mercurial/revset.py Wed Mar 18 20:40:02 2015 -0700
+++ b/mercurial/revset.py Mon Mar 16 18:15:06 2015 +0900
@@ -2836,6 +2836,10 @@
return self._asclist[0]
return None
+ def __repr__(self):
+ d = {None: '', False: '-', True: '+'}[self._ascending]
+ return '<%s%s %r>' % (type(self).__name__, d, self._list)
+
class filteredset(abstractsmartset):
"""Duck type for baseset class which iterates lazily over the revisions in
the subset and contains a function which tests for membership in the
@@ -2920,6 +2924,9 @@
return x
return None
+ def __repr__(self):
+ return '<%s %r>' % (type(self).__name__, self._subset)
+
class addset(abstractsmartset):
"""Represent the addition of two sets
@@ -3093,6 +3100,10 @@
self.reverse()
return val
+ def __repr__(self):
+ d = {None: '', False: '-', True: '+'}[self._ascending]
+ return '<%s%s %r, %r>' % (type(self).__name__, d, self._r1, self._r2)
+
class generatorset(abstractsmartset):
"""Wrap a generator for lazy iteration
@@ -3262,6 +3273,10 @@
return it().next()
return None
+ def __repr__(self):
+ d = {False: '-', True: '+'}[self._ascending]
+ return '<%s%s>' % (type(self).__name__, d)
+
class spanset(abstractsmartset):
"""Duck type for baseset class which represents a range of revisions and
can work lazily and without having all the range in memory
@@ -3366,6 +3381,11 @@
return x
return None
+ def __repr__(self):
+ d = {False: '-', True: '+'}[self._ascending]
+ return '<%s%s %d:%d>' % (type(self).__name__, d,
+ self._start, self._end - 1)
+
class fullreposet(spanset):
"""a set containing all revisions in the repo