Patchwork smartset: reorder initialization of baseset in more intuitive way

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 18, 2017, 9:48 a.m.
Message ID <1ca3469fdd08c0d5d814.1487411286@mimosa>
Download mbox | patch
Permalink /patch/18643/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Yuya Nishihara - Feb. 18, 2017, 9:48 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.
Jun Wu - Feb. 19, 2017, 1:39 a.m.
Looks good to me. Thanks for the clean-up!

Excerpts from Yuya Nishihara's message of 2017-02-18 18:48:06 +0900:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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
>
via Mercurial-devel - Feb. 28, 2017, 9:37 p.m.
On Sat, Feb 18, 2017 at 5:39 PM, Jun Wu <quark@fb.com> wrote:
> Looks good to me. Thanks for the clean-up!

Yep, looks good. Queued, thanks. And sorry about the delay.

>
> Excerpts from Yuya Nishihara's message of 2017-02-18 18:48:06 +0900:
>> # HG changeset patch
>> # User Yuya Nishihara <yuya@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
>>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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