[PATCH] smartset: reorder initialization of baseset in more intuitive way

Yuya Nishihara yuya at tcha.org
Sat Feb 18 09:48:06 UTC 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1487407072 -32400
#      Sat Feb 18 17:37:52 2017 +0900
# Node ID 1ca3469fdd08c0d5d814a4bc359869bc157c7fc9
# Parent  3f4bdcfe63e9f1e357187fa728ae0da9d35b3973
smartset: reorder initialization of baseset in more intuitive way

What we want to do is to assign either _set or _list per the given data
type.

diff --git a/mercurial/smartset.py b/mercurial/smartset.py
--- a/mercurial/smartset.py
+++ b/mercurial/smartset.py
@@ -166,16 +166,14 @@ class baseset(abstractsmartset):
         """
         self._ascending = None
         self._istopo = istopo
-        if not isinstance(data, list):
-            if isinstance(data, set):
-                self._set = data
-                # set has no order we pick one for stability purpose
-                self._ascending = True
-                # converting set to list has a cost, do it lazily
-                data = None
-            else:
+        if isinstance(data, set):
+            # converting set to list has a cost, do it lazily
+            self._set = data
+            # set has no order we pick one for stability purpose
+            self._ascending = True
+        else:
+            if not isinstance(data, list):
                 data = list(data)
-        if data is not None:
             self._list = data
         self._datarepr = datarepr
 


More information about the Mercurial-devel mailing list