[PATCH 5 of 6] revset: make addset class accepts more than two subsets (issue4565)

Yuya Nishihara yuya at tcha.org
Wed May 13 09:43:39 CDT 2015


On Tue, 12 May 2015 17:55:26 -0700, Pierre-Yves David wrote:
> On 05/12/2015 03:59 PM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya at tcha.org>
> > # Date 1426404911 -32400
> > #      Sun Mar 15 16:35:11 2015 +0900
> > # Node ID d15815ca13aec24b6c62d2ec2eebebea52adc411
> > # Parent  1ef1b51bba52a6d186fdbc794045eec6b6477be0
> > revset: make addset class accepts more than two subsets (issue4565)
> >
> > This allows us to handle chained OR operations in one addset instance, which
> > should greatly reduce the usage of Python stack.
> 
> The way most python's API usually work on this aspect is by taking an 
> arbitrary number of arguments:
> 
>  >>> max(1, 2, 3, 4, 5, 6)
> 
> we could do the same here:
> 
>  >>> addset(x1, x2)
>  >>> addset(x1, x2, x3)
> 
> what do you think ?

It could, but I'll change addset to be constructed from a list in order to
fix issue4624. So addset(*subsets) won't be so useful.

-def orset(repo, subset, x, y):
-    xl = getset(repo, subset, x)
-    yl = getset(repo, subset, y)
-    return xl + yl
+def orset(repo, subset, *xs):
+    return addset([getset(repo, subset, x) for x in xs])


More information about the Mercurial-devel mailing list