Patchwork [6,V2] revset: parse nullary ":" operator as "0:tip"

login
register
mail settings
Submitter Yuya Nishihara
Date July 18, 2015, 1:45 p.m.
Message ID <20150718224534.1c36f85f4b6684971275c438@tcha.org>
Download mbox | patch
Permalink /patch/10034/
State Accepted
Headers show

Comments

Yuya Nishihara - July 18, 2015, 1:45 p.m.
Could you drop the PATCH 5, "parser: remove unused binding parameter from
suffix action" ?

If we want to parse 'a^:b' as '(a^):b', not 'a^(:b)', we might need the binding
value of the next infix/suffix action.

This is the PATCH 6 rebased onto the PATCH 4.

# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1436066154 -32400
#      Sun Jul 05 12:15:54 2015 +0900
# Node ID 8d2391785ecb870cc0aa06acc6ae0a734075bd69
# Parent  3cdc85527cbbe58d148e3c2d9bdeb3281acb1976
revset: parse nullary ":" operator as "0:tip"

This is necessary for compatibility with the old-style parser that will be
removed by future patches.
Matt Mackall - July 18, 2015, 6:51 p.m.
On Sat, 2015-07-18 at 22:45 +0900, Yuya Nishihara wrote:
> Could you drop the PATCH 5, "parser: remove unused binding parameter from
> suffix action" ?

Sure, this is queued.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -125,7 +125,7 @@  elements = {
            ("dagrangepost", 17)),
     "..": (17, None, ("dagrangepre", 17), ("dagrange", 17),
            ("dagrangepost", 17)),
-    ":": (15, None, ("rangepre", 15), ("range", 15), ("rangepost", 15)),
+    ":": (15, "rangeall", ("rangepre", 15), ("range", 15), ("rangepost", 15)),
     "not": (10, None, ("not", 10), None, None),
     "!": (10, None, ("not", 10), None, None),
     "and": (5, None, None, ("and", 5), None),
@@ -2227,6 +2227,8 @@  def optimize(x, small):
         return optimize(('func', ('symbol', 'ancestors'), x[1]), small)
     elif op == 'dagrangepost':
         return optimize(('func', ('symbol', 'descendants'), x[1]), small)
+    elif op == 'rangeall':
+        return optimize(('range', ('string', '0'), ('string', 'tip')), small)
     elif op == 'rangepre':
         return optimize(('range', ('string', '0'), x[1]), small)
     elif op == 'rangepost':
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -117,6 +117,25 @@  trivial
   <spanset+ 0:1>
   0
   1
+  $ try --optimize :
+  (rangeall
+    None)
+  * optimized:
+  (range
+    ('string', '0')
+    ('string', 'tip'))
+  * set:
+  <spanset+ 0:9>
+  0
+  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
   $ try 3::6
   (dagrange
     ('symbol', '3')