[PATCH] smartset: preserve istopo for baseset operations

Jun Wu quark at fb.com
Wed Feb 22 00:33:56 UTC 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1487723371 28800
#      Tue Feb 21 16:29:31 2017 -0800
# Node ID 70e221675023dc23b5da10ae0c1d6baffdd6dd93
# Parent  37ab9e20991c1d39014db8297065357fbded0213
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 70e221675023
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.

diff --git a/mercurial/smartset.py b/mercurial/smartset.py
--- a/mercurial/smartset.py
+++ b/mercurial/smartset.py
@@ -204,4 +204,12 @@ class baseset(abstractsmartset):
     >>> [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):
@@ -327,5 +335,6 @@ class baseset(abstractsmartset):
         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:


More information about the Mercurial-devel mailing list