[PATCH 2 of 2] revset: make optimizer use the new minusset
Martin von Zweigbergk
martinvonz at google.com
Thu Feb 11 13:44:25 EST 2016
On Thu, Feb 11, 2016 at 10:14 AM, Martin von Zweigbergk
<martinvonz at google.com> wrote:
> I'm new to the revset code, so please forgive me if the below makes no sense.
>
> On Wed, Feb 10, 2016 at 4:23 PM, Durham Goode <durham at fb.com> wrote:
>> # HG changeset patch
>> # User Durham Goode <durham at fb.com>
>> # Date 1455146394 28800
>> # Wed Feb 10 15:19:54 2016 -0800
>> # Node ID ec633f772ea500d3db5e2fff3240099960f679b3
>> # Parent edfc4fda0c1ca78186d9a779f0d4d0cfc6e1c03f
>> revset: make optimizer use the new minusset
>>
>> Now that we have a minusset class, we need to change the optimizer to use it.
>
> It seems to me that these two patches do two things:
>
> 1) Tell the optimizer to use use the revset's '-' operator (i.e.
> abstractsmartset.__sub__()) when the user used '-' in the expression.
> These are the changes to revset.py in this patch, except for the the
> hunk starting on line 2846.
To also get the speedup when the user explicitly types "x and not y"
(not "x - y"), perhaps something as simple as the below is enough for
step 1)? It seems enough on the few examples I've tested.
diff -r a036e1ae1fbe -r 164acb043741 mercurial/revset.py
--- a/mercurial/revset.py Sun Feb 07 00:49:31 2016 -0600
+++ b/mercurial/revset.py Thu Feb 11 10:36:01 2016 -0800
@@ -436,6 +436,9 @@
def andset(repo, subset, x, y):
return getset(repo, getset(repo, subset, x), y)
+def minusset(repo, subset, x, y):
+ return getset(repo, subset, x) - getset(repo, subset, y)
+
def orset(repo, subset, *xs):
assert xs
if len(xs) == 1:
@@ -2145,6 +2148,7 @@
"and": andset,
"or": orset,
"not": notset,
+ "minusset": minusset,
"list": listset,
"keyvalue": keyvaluepair,
"func": func,
@@ -2205,6 +2209,9 @@
if isonly(tb, ta):
return w, ('func', ('symbol', 'only'), ('list', tb[2], ta[1][2]))
+ if tb is not None and tb[0] == 'not':
+ return wa, ('minusset', ta, tb[1])
+
if wa > wb:
return w, (op, tb, ta)
return w, (op, ta, tb)
More information about the Mercurial-devel
mailing list