# HG changeset patch # User Pierre-Yves David # Date 1412618610 25200 # Node ID 0e8bb81b58b9b29969b40db1d78b8b675fdb2805 # Parent 9271630f472068bcf85130c7020c685cd908e078 baseset: stop inheriting from built-in list class The baseset is doing more and more smartset magic and using its list-like property less and less. So we store the list of revisions in an explicit attribute and stop inheriting. This requires reimplementing some basic methods. diff -r 9271630f4720 -r 0e8bb81b58b9 mercurial/revset.py --- a/mercurial/revset.py Tue Oct 07 00:38:14 2014 -0700 +++ b/mercurial/revset.py Mon Oct 06 11:03:30 2014 -0700 @@ -2320,14 +2320,16 @@ kwargs['ascending'] = False return filteredset(self, condition, **kwargs) -class baseset(list, abstractsmartset): +class baseset(abstractsmartset): """Basic data structure that represents a revset and contains the basic operation that it should be able to perform. Every method in this class should be implemented by any smartset class. """ def __init__(self, data=()): - super(baseset, self).__init__(data) + if not isinstance(data, list): + data = list(data) + self._list = data self._set = None def set(self): @@ -2346,7 +2348,19 @@ return self.set().__contains__ def __nonzero__(self): - return bool(len(self)) + return bool(self._list) + + def sort(self, reverse=False): + self._list.sort(reverse=reverse) + + def reverse(self): + self._list.reverse() + + def __iter__(self): + return iter(self._list) + + def __len__(self): + return len(self._list) def __sub__(self, other): """Returns a new object with the substraction of the two collections. @@ -2389,12 +2403,12 @@ def first(self): if self: - return self[0] + return self._list[0] return None def last(self): if self: - return self[-1] + return self._list[-1] return None class filteredset(abstractsmartset):