mercurial/smartset.py
changeset 32820 653d60455dbe
parent 32819 4710cc4dac99
child 32821 9b7d615108d7
--- a/mercurial/smartset.py	Tue Mar 24 00:14:53 2015 +0900
+++ b/mercurial/smartset.py	Thu Apr 09 23:56:06 2015 +0900
@@ -372,6 +372,18 @@
     def __sub__(self, other):
         return self._fastsetop(other, '__sub__')
 
+    def _slice(self, start, stop):
+        # creating new list should be generally cheaper than iterating items
+        if self._ascending is None:
+            return baseset(self._list[start:stop], istopo=self._istopo)
+
+        data = self._asclist
+        if not self._ascending:
+            start, stop = max(len(data) - stop, 0), max(len(data) - start, 0)
+        s = baseset(data[start:stop], istopo=self._istopo)
+        s._ascending = self._ascending
+        return s
+
     def __repr__(self):
         d = {None: '', False: '-', True: '+'}[self._ascending]
         s = _formatsetrepr(self._datarepr)