changeset 31083:c962bb6af909

smartset: preserve istopo for baseset operations This is a follow-up of "smartset: use native set operations as fast paths". It's more correct to just preserve the "istopo" information for "&" and "-" operations, like what filteredset does.
author Jun Wu <quark@fb.com>
date Tue, 21 Feb 2017 16:29:31 -0800
parents 88203f26ea57
children a0bde5ec3a46
files mercurial/smartset.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/smartset.py	Tue Feb 07 17:13:25 2017 -0500
+++ b/mercurial/smartset.py	Tue Feb 21 16:29:31 2017 -0800
@@ -203,6 +203,14 @@
     [[7, 6, 4, 0, 3, 5], [7, 6], [4, 0]]
     >>> [type(i).__name__ for i in [xs + ys, xs & ys, xs - ys]]
     ['addset', 'baseset', 'baseset']
+
+    istopo is preserved across set operations
+    >>> xs = baseset(set(x), istopo=True)
+    >>> rs = xs & ys
+    >>> type(rs).__name__
+    'baseset'
+    >>> rs._istopo
+    True
     """
     def __init__(self, data=(), datarepr=None, istopo=False):
         """
@@ -326,7 +334,8 @@
         # try to use native set operations as fast paths
         if (type(other) is baseset and '_set' in other.__dict__ and '_set' in
             self.__dict__ and self._ascending is not None):
-            s = baseset(data=getattr(self._set, op)(other._set))
+            s = baseset(data=getattr(self._set, op)(other._set),
+                        istopo=self._istopo)
             s._ascending = self._ascending
         else:
             s = getattr(super(baseset, self), op)(other)