Patchwork [1,of,2] revset: replace _missingancestors optimization with only revset

login
register
mail settings
Submitter Siddharth Agarwal
Date July 12, 2014, 7:38 a.m.
Message ID <8686541e5772e8cdb30f.1405150693@dev1738.prn1.facebook.com>
Download mbox | patch
Permalink /patch/5142/
State Superseded
Commit e967c3b08705b50a394d92539e31fee8a9ce3381
Headers show

Comments

Siddharth Agarwal - July 12, 2014, 7:38 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1405150296 25200
#      Sat Jul 12 00:31:36 2014 -0700
# Node ID 8686541e5772e8cdb30f435fe9b7ca219dee9f2a
# Parent  ba3bc6474bbf3a29e5fa16d13ff44b9c0848043c
revset: replace _missingancestors optimization with only revset

(::a - ::b) is equivalent to only(a, b).
Siddharth Agarwal - July 12, 2014, 7:39 a.m.
On 07/12/2014 12:38 AM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1405150296 25200
> #      Sat Jul 12 00:31:36 2014 -0700
> # Node ID 8686541e5772e8cdb30f435fe9b7ca219dee9f2a
> # Parent  ba3bc6474bbf3a29e5fa16d13ff44b9c0848043c
> revset: replace _missingancestors optimization with only revset

I missed one instance here. Resending.

>
> (::a - ::b) is equivalent to only(a, b).
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -1867,7 +1867,7 @@
>           wb, tb = optimize(x[2], True)
>   
>           # (::x and not ::y)/(not ::y and ::x) have a fast path
> -        def ismissingancestors(revs, bases):
> +        def isonly(revs, bases):
>               return (
>                   revs[0] == 'func'
>                   and getstring(revs[1], _('not a symbol')) == 'ancestors'
> @@ -1876,12 +1876,10 @@
>                   and getstring(bases[1][1], _('not a symbol')) == 'ancestors')
>   
>           w = min(wa, wb)
> -        if ismissingancestors(ta, tb):
> -            return w, ('func', ('symbol', '_missingancestors'),
> -                       ('list', ta[2], tb[1][2]))
> -        if ismissingancestors(tb, ta):
> -            return w, ('func', ('symbol', '_missingancestors'),
> -                       ('list', tb[2], ta[1][2]))
> +        if isonly(ta, tb):
> +            return w, ('func', ('symbol', 'only'), ('list', ta[2], tb[1][2]))
> +        if isonly(tb, ta):
> +            return w, ('func', ('symbol', 'only'), ('list', tb[2], ta[1][2]))
>   
>           if wa > wb:
>               return w, (op, tb, ta)
> diff --git a/tests/test-revset.t b/tests/test-revset.t
> --- a/tests/test-revset.t
> +++ b/tests/test-revset.t
> @@ -571,7 +571,7 @@
>         ('symbol', '1')))
>     * optimized:
>     (func
> -    ('symbol', '_missingancestors')
> +    ('symbol', 'only')
>       (list
>         ('symbol', '3')
>         ('symbol', '1')))
> @@ -586,7 +586,7 @@
>         ('symbol', '3')))
>     * optimized:
>     (func
> -    ('symbol', '_missingancestors')
> +    ('symbol', 'only')
>       (list
>         ('symbol', '1')
>         ('symbol', '3')))
> @@ -599,7 +599,7 @@
>         ('symbol', '6')))
>     * optimized:
>     (func
> -    ('symbol', '_missingancestors')
> +    ('symbol', 'only')
>       (list
>         ('symbol', '6')
>         ('symbol', '2')))
> @@ -618,7 +618,7 @@
>           ('symbol', '4'))))
>     * optimized:
>     (func
> -    ('symbol', '_missingancestors')
> +    ('symbol', 'only')
>       (list
>         ('symbol', '6')
>         ('symbol', '4')))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1867,7 +1867,7 @@ 
         wb, tb = optimize(x[2], True)
 
         # (::x and not ::y)/(not ::y and ::x) have a fast path
-        def ismissingancestors(revs, bases):
+        def isonly(revs, bases):
             return (
                 revs[0] == 'func'
                 and getstring(revs[1], _('not a symbol')) == 'ancestors'
@@ -1876,12 +1876,10 @@ 
                 and getstring(bases[1][1], _('not a symbol')) == 'ancestors')
 
         w = min(wa, wb)
-        if ismissingancestors(ta, tb):
-            return w, ('func', ('symbol', '_missingancestors'),
-                       ('list', ta[2], tb[1][2]))
-        if ismissingancestors(tb, ta):
-            return w, ('func', ('symbol', '_missingancestors'),
-                       ('list', tb[2], ta[1][2]))
+        if isonly(ta, tb):
+            return w, ('func', ('symbol', 'only'), ('list', ta[2], tb[1][2]))
+        if isonly(tb, ta):
+            return w, ('func', ('symbol', 'only'), ('list', tb[2], ta[1][2]))
 
         if wa > wb:
             return w, (op, tb, ta)
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -571,7 +571,7 @@ 
       ('symbol', '1')))
   * optimized:
   (func
-    ('symbol', '_missingancestors')
+    ('symbol', 'only')
     (list
       ('symbol', '3')
       ('symbol', '1')))
@@ -586,7 +586,7 @@ 
       ('symbol', '3')))
   * optimized:
   (func
-    ('symbol', '_missingancestors')
+    ('symbol', 'only')
     (list
       ('symbol', '1')
       ('symbol', '3')))
@@ -599,7 +599,7 @@ 
       ('symbol', '6')))
   * optimized:
   (func
-    ('symbol', '_missingancestors')
+    ('symbol', 'only')
     (list
       ('symbol', '6')
       ('symbol', '2')))
@@ -618,7 +618,7 @@ 
         ('symbol', '4'))))
   * optimized:
   (func
-    ('symbol', '_missingancestors')
+    ('symbol', 'only')
     (list
       ('symbol', '6')
       ('symbol', '4')))