@@ -2288,7 +2288,9 @@ class baseset(list):
This is part of the mandatory API for smartset."""
if isinstance(other, baseset):
other = other.set()
- return baseset([y for y in self if y in other])
+
+ iterate, check = _optimize_and(self, other)
+ return baseset([y for y in iterate if y in check])
def __add__(self, other):
"""Returns a new object with the union of the two collections.
@@ -2390,7 +2392,8 @@ class lazyset(object):
yield x
def __and__(self, x):
- return lazyset(self, x.__contains__)
+ iterate, check = _optimize_and(self, x)
+ return lazyset(iterate, check.__contains__)
def __sub__(self, x):
return lazyset(self, lambda r: r not in x)
@@ -2456,7 +2459,8 @@ class orderedlazyset(_orderedsetmixin, l
self.reverse()
def __and__(self, x):
- return orderedlazyset(self, x.__contains__,
+ iterate, check = _optimize_and(self, x)
+ return orderedlazyset(iterate, check.__contains__,
ascending=self._ascending)
def __sub__(self, x):
@@ -2544,10 +2548,12 @@ class _addset(_orderedsetmixin):
self.reverse()
def __and__(self, other):
- filterfunc = other.__contains__
- if self._ascending is not None:
- return orderedlazyset(self, filterfunc, ascending=self._ascending)
- return lazyset(self, filterfunc)
+ iterate, check = _optimize_and(self, other)
+ filterfunc = check.__contains__
+ if iterate._ascending is not None:
+ return orderedlazyset(iterate, filterfunc,
+ ascending=iterate._ascending)
+ return lazyset(iterate, filterfunc)
def __sub__(self, other):
filterfunc = lambda r: r not in other
@@ -2861,7 +2867,9 @@ class _spanset(_orderedsetmixin):
def __and__(self, x):
if isinstance(x, baseset):
x = x.set()
- return orderedlazyset(self, x.__contains__,
+
+ iterate, check = _optimize_and(self, x)
+ return orderedlazyset(iterate, check.__contains__,
ascending=self.isascending())
def __sub__(self, x):
@@ -626,12 +626,6 @@ each root have a different common ancest
$ hg rebase --dest 'desc(G)' --rev 'desc(K) + desc(I)'
saved backup bundle to $TESTTMP/a8/.hg/strip-backup/e7ec4e813ba6-backup.hg (glob)
$ hg log --rev 'children(desc(G))'
- changeset: 9:adb617877056
- parent: 6:eea13746799a
- user: test
- date: Thu Jan 01 00:00:00 1970 +0000
- summary: I
-
changeset: 10:882431a34a0e
tag: tip
parent: 6:eea13746799a
@@ -639,6 +633,12 @@ each root have a different common ancest
date: Thu Jan 01 00:00:00 1970 +0000
summary: K
+ changeset: 9:adb617877056
+ parent: 6:eea13746799a
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: I
+
$ hg tglog
@ 10: 'K'
|
@@ -273,8 +273,8 @@ ancestor can accept 0 or more arguments
6 _a_b_c_
7 .a.b.c.
$ log 'children(ancestor(4,5))'
+ 3
2
- 3
$ log 'closed()'
$ log 'contains(a)'
0