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

Yuya Nishihara yuya at tcha.org
Sat Jul 18 08:45:34 CDT 2015


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 at 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.

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')



More information about the Mercurial-devel mailing list