Patchwork [2,of,2] revset: changed __add__ methods on lazy sets to return addsets (issue4191)

login
register
mail settings
Submitter Lucas Moscovicz
Date March 7, 2014, 10:31 p.m.
Message ID <0404c3f5df5fd52d3046.1394231517@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3887/
State Accepted
Commit d99fcf4483f8544ede823d08a8319f728e44ac2c
Headers show

Comments

Lucas Moscovicz - March 7, 2014, 10:31 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1394230009 28800
#      Fri Mar 07 14:06:49 2014 -0800
# Node ID 0404c3f5df5fd52d304611b6d55a4ac72fb40a54
# Parent  b590b0931be764118f54a00e1316d19b4b4573ed
revset: changed __add__ methods on lazy sets to return addsets (issue4191)

Performance Benchmarking:

$ hg --time log --graph --style compact --limit 6 -r 'sort((::. or bookmark()
or heads(public())), "-rev")'
time: real 1.540 secs (user 1.510+0.000 sys 0.020+0.000)

$ ./hg --time log --graph --style compact --limit 6 -r 'sort((::. or
bookmark() or heads(public())), "-rev")'
time: real 1.240 secs (user 1.190+0.000 sys 0.040+0.010)
Matt Mackall - March 12, 2014, 9:02 p.m.
On Fri, 2014-03-07 at 14:31 -0800, Lucas Moscovicz wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz@fb.com>
> # Date 1394230009 28800
> #      Fri Mar 07 14:06:49 2014 -0800
> # Node ID 0404c3f5df5fd52d304611b6d55a4ac72fb40a54
> # Parent  b590b0931be764118f54a00e1316d19b4b4573ed
> revset: changed __add__ methods on lazy sets to return addsets (issue4191)

These are queued for default, thanks.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2212,14 +2212,7 @@ 
         return lazyset(self, lambda r: r not in x)
 
     def __add__(self, x):
-        def iterates():
-            for r in self:
-                yield r
-            for r in x:
-                if r not in self:
-                    yield r
-
-        return lazyset(generatorset(iterates()))
+        return lazyset(addset(self, x))
 
     def __nonzero__(self):
         for r in self:
@@ -2454,14 +2447,7 @@ 
             return orderedlazyset(self, lambda r: r not in x, ascending=False)
 
     def __add__(self, x):
-        def iterates():
-            for r in self:
-                yield r
-            for r in x:
-                if r not in self:
-                    yield r
-
-        return lazyset(generatorset(iterates()))
+        return lazyset(addset(self, x))
 
     def __len__(self):
         if not self._hiddenrevs: