Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 28425:02d7faaf455c
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 16 Feb 2016 21:32:00 +0900 |
parents | 534f968d33e5 |
children | 3d39ac06af9a |
comparison
equal
deleted
inserted
replaced
28424:534f968d33e5 | 28425:02d7faaf455c |
---|---|
2883 """Basic data structure that represents a revset and contains the basic | 2883 """Basic data structure that represents a revset and contains the basic |
2884 operation that it should be able to perform. | 2884 operation that it should be able to perform. |
2885 | 2885 |
2886 Every method in this class should be implemented by any smartset class. | 2886 Every method in this class should be implemented by any smartset class. |
2887 """ | 2887 """ |
2888 def __init__(self, data=()): | 2888 def __init__(self, data=(), datarepr=None): |
2889 """ | |
2890 datarepr: a tuple of (format, obj, ...), a function or an object that | |
2891 provides a printable representation of the given data. | |
2892 """ | |
2889 if not isinstance(data, list): | 2893 if not isinstance(data, list): |
2890 if isinstance(data, set): | 2894 if isinstance(data, set): |
2891 self._set = data | 2895 self._set = data |
2892 data = list(data) | 2896 data = list(data) |
2893 self._list = data | 2897 self._list = data |
2898 self._datarepr = datarepr | |
2894 self._ascending = None | 2899 self._ascending = None |
2895 | 2900 |
2896 @util.propertycache | 2901 @util.propertycache |
2897 def _set(self): | 2902 def _set(self): |
2898 return set(self._list) | 2903 return set(self._list) |
2972 return self._asclist[0] | 2977 return self._asclist[0] |
2973 return None | 2978 return None |
2974 | 2979 |
2975 def __repr__(self): | 2980 def __repr__(self): |
2976 d = {None: '', False: '-', True: '+'}[self._ascending] | 2981 d = {None: '', False: '-', True: '+'}[self._ascending] |
2977 return '<%s%s %r>' % (type(self).__name__, d, self._list) | 2982 s = _formatsetrepr(self._datarepr) |
2983 if not s: | |
2984 s = repr(self._list) | |
2985 return '<%s%s %s>' % (type(self).__name__, d, s) | |
2978 | 2986 |
2979 class filteredset(abstractsmartset): | 2987 class filteredset(abstractsmartset): |
2980 """Duck type for baseset class which iterates lazily over the revisions in | 2988 """Duck type for baseset class which iterates lazily over the revisions in |
2981 the subset and contains a function which tests for membership in the | 2989 the subset and contains a function which tests for membership in the |
2982 revset | 2990 revset |