revset: stub to add extra data to baseset for better inspection
authorYuya Nishihara <yuya@tcha.org>
Tue, 16 Feb 2016 21:32:00 +0900
changeset 28425 02d7faaf455c
parent 28424 534f968d33e5
child 28426 3d39ac06af9a
revset: stub to add extra data to baseset for better inspection We sometimes construct a baseset from filtering result. In that case, a baseset can provide more precise information how it is constructed.
mercurial/revset.py
--- a/mercurial/revset.py	Sat Feb 13 20:05:57 2016 +0900
+++ b/mercurial/revset.py	Tue Feb 16 21:32:00 2016 +0900
@@ -2885,12 +2885,17 @@
 
     Every method in this class should be implemented by any smartset class.
     """
-    def __init__(self, data=()):
+    def __init__(self, data=(), datarepr=None):
+        """
+        datarepr: a tuple of (format, obj, ...), a function or an object that
+                  provides a printable representation of the given data.
+        """
         if not isinstance(data, list):
             if isinstance(data, set):
                 self._set = data
             data = list(data)
         self._list = data
+        self._datarepr = datarepr
         self._ascending = None
 
     @util.propertycache
@@ -2974,7 +2979,10 @@
 
     def __repr__(self):
         d = {None: '', False: '-', True: '+'}[self._ascending]
-        return '<%s%s %r>' % (type(self).__name__, d, self._list)
+        s = _formatsetrepr(self._datarepr)
+        if not s:
+            s = repr(self._list)
+        return '<%s%s %s>' % (type(self).__name__, d, s)
 
 class filteredset(abstractsmartset):
     """Duck type for baseset class which iterates lazily over the revisions in