Patchwork [4,of,4] revset: added basic operators to orderedlazyset

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 27, 2014, 11:54 p.m.
Message ID <d9c1f97dac5f752a9def.1393545252@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3799/
State Accepted
Commit 60c308b932ebd8a77f497ae285774fdced382eee
Headers show

Comments

Lucas Moscovicz - Feb. 27, 2014, 11:54 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1391737328 28800
#      Thu Feb 06 17:42:08 2014 -0800
# Node ID d9c1f97dac5f752a9def8f03bcb6604b8ee05c39
# Parent  7a2d42d243dcc61aad03d90ee83e0878fef7cd12
revset: added basic operators to orderedlazyset

Now __add__ and __sub__ return orderedlazyset.
Simon King - Feb. 28, 2014, 9:44 a.m.
On Thu, Feb 27, 2014 at 11:54 PM, Lucas Moscovicz <lmoscovicz@fb.com> wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz@fb.com>
> # Date 1391737328 28800
> #      Thu Feb 06 17:42:08 2014 -0800
> # Node ID d9c1f97dac5f752a9def8f03bcb6604b8ee05c39
> # Parent  7a2d42d243dcc61aad03d90ee83e0878fef7cd12
> revset: added basic operators to orderedlazyset
>
> Now __add__ and __sub__ return orderedlazyset.
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -2221,6 +2221,14 @@
>      def filter(self, l):
>          return orderedlazyset(self, l, ascending=self._ascending)
>
> +    def __and__(self, x):
> +        return orderedlazyset(self, lambda r: r in x,
> +                ascending=self._ascending)

Is this a typo? The patch description says __add__, but the method
you've added is __and__.

Simon
Lucas Moscovicz - Feb. 28, 2014, 4:11 p.m.
On 2/28/14, 1:44 AM, "Simon King" <simon@simonking.org.uk> wrote:

>On Thu, Feb 27, 2014 at 11:54 PM, Lucas Moscovicz <lmoscovicz@fb.com>
>wrote:
>> # HG changeset patch
>> # User Lucas Moscovicz <lmoscovicz@fb.com>
>> # Date 1391737328 28800
>> #      Thu Feb 06 17:42:08 2014 -0800
>> # Node ID d9c1f97dac5f752a9def8f03bcb6604b8ee05c39
>> # Parent  7a2d42d243dcc61aad03d90ee83e0878fef7cd12
>> revset: added basic operators to orderedlazyset
>>
>> Now __add__ and __sub__ return orderedlazyset.
>>
>> diff --git a/mercurial/revset.py b/mercurial/revset.py
>> --- a/mercurial/revset.py
>> +++ b/mercurial/revset.py
>> @@ -2221,6 +2221,14 @@
>>      def filter(self, l):
>>          return orderedlazyset(self, l, ascending=self._ascending)
>>
>> +    def __and__(self, x):
>> +        return orderedlazyset(self, lambda r: r in x,
>> +                ascending=self._ascending)
>
>Is this a typo? The patch description says __add__, but the method
>you've added is __and__.

Yes, its a typo, the description should say __and__.

>
>Simon
Matt Mackall - Feb. 28, 2014, 8:34 p.m.
On Thu, 2014-02-27 at 15:54 -0800, Lucas Moscovicz wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz@fb.com>
> # Date 1391737328 28800
> #      Thu Feb 06 17:42:08 2014 -0800
> # Node ID d9c1f97dac5f752a9def8f03bcb6604b8ee05c39
> # Parent  7a2d42d243dcc61aad03d90ee83e0878fef7cd12
> revset: added basic operators to orderedlazyset

These are queued for default, thanks. Typo fixed.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2221,6 +2221,14 @@ 
     def filter(self, l):
         return orderedlazyset(self, l, ascending=self._ascending)
 
+    def __and__(self, x):
+        return orderedlazyset(self, lambda r: r in x,
+                ascending=self._ascending)
+
+    def __sub__(self, x):
+        return orderedlazyset(self, lambda r: r not in x,
+                ascending=self._ascending)
+
 class generatorset(object):
     """Wrapper structure for generators that provides lazy membership and can
     be iterated more than once.