Patchwork [2,of,5] revset: add test for resolution of infix/suffix ambiguity of x^:y

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 8, 2016, 3:25 p.m.
Message ID <3f08020d8a710f5a3bee.1470669921@mimosa>
Download mbox | patch
Permalink /patch/16199/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 8, 2016, 3:25 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1470481168 -32400
#      Sat Aug 06 19:59:28 2016 +0900
# Node ID 3f08020d8a710f5a3bee7e88452faccacf800c6c
# Parent  bf733d2494a59338b16df8dbb7101de4697e1e90
revset: add test for resolution of infix/suffix ambiguity of x^:y

This is the test for 805651777188, and I'm going to fix the failure of
'x^A' where 'revsetalias.A=:y'.

Patch

diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -478,6 +478,191 @@  parenthesis.
   8
   9
 
+infix/suffix resolution of ^ operator (issue2884):
+
+ x^:y means (x^):y
+
+  $ try --optimize '1^:2'
+  (parent
+    ('symbol', '1')
+    (rangepre
+      ('symbol', '2')))
+  * optimized:
+  (range
+    (parentpost
+      ('symbol', '1'))
+    ('symbol', '2'))
+  * set:
+  <spanset+ 0:2>
+  0
+  1
+  2
+
+  $ try --optimize '1^::2'
+  (parent
+    ('symbol', '1')
+    (dagrangepre
+      ('symbol', '2')))
+  * optimized:
+  (dagrange
+    (parentpost
+      ('symbol', '1'))
+    ('symbol', '2'))
+  * set:
+  <baseset+ [0, 1, 2]>
+  0
+  1
+  2
+
+ x^:y should be resolved before omitting group operators
+
+  $ try --optimize '1^(:2)'
+  (parent
+    ('symbol', '1')
+    (group
+      (rangepre
+        ('symbol', '2'))))
+  * optimized:
+  (parent
+    ('symbol', '1')
+    (range
+      ('string', '0')
+      ('symbol', '2')))
+  hg: parse error: ^ expects a number 0, 1, or 2
+  [255]
+
+ x^:y should be resolved recursively
+
+  $ try --optimize 'sort(1^:2)'
+  (func
+    ('symbol', 'sort')
+    (parent
+      ('symbol', '1')
+      (rangepre
+        ('symbol', '2'))))
+  * optimized:
+  (func
+    ('symbol', 'sort')
+    (range
+      (parentpost
+        ('symbol', '1'))
+      ('symbol', '2')))
+  * set:
+  <spanset+ 0:2>
+  0
+  1
+  2
+
+  $ try --optimize '(3^:4)^:2'
+  (parent
+    (group
+      (parent
+        ('symbol', '3')
+        (rangepre
+          ('symbol', '4'))))
+    (rangepre
+      ('symbol', '2')))
+  * optimized:
+  (range
+    (parentpost
+      (range
+        (parentpost
+          ('symbol', '3'))
+        ('symbol', '4')))
+    ('symbol', '2'))
+  * set:
+  <spanset+ 0:2>
+  0
+  1
+  2
+
+  $ try --optimize '(3^::4)^::2'
+  (parent
+    (group
+      (parent
+        ('symbol', '3')
+        (dagrangepre
+          ('symbol', '4'))))
+    (dagrangepre
+      ('symbol', '2')))
+  * optimized:
+  (dagrange
+    (parentpost
+      (dagrange
+        (parentpost
+          ('symbol', '3'))
+        ('symbol', '4')))
+    ('symbol', '2'))
+  * set:
+  <baseset+ [0, 1, 2]>
+  0
+  1
+  2
+
+ x^ in alias should also be resolved
+
+  $ try --optimize 'A' --config 'revsetalias.A=1^:2'
+  ('symbol', 'A')
+  * expanded:
+  (parent
+    ('symbol', '1')
+    (rangepre
+      ('symbol', '2')))
+  * optimized:
+  (range
+    (parentpost
+      ('symbol', '1'))
+    ('symbol', '2'))
+  * set:
+  <spanset+ 0:2>
+  0
+  1
+  2
+
+  $ try --optimize 'A:2' --config 'revsetalias.A=1^'
+  (range
+    ('symbol', 'A')
+    ('symbol', '2'))
+  * expanded:
+  (range
+    (parentpost
+      ('symbol', '1'))
+    ('symbol', '2'))
+  * optimized:
+  (range
+    (parentpost
+      ('symbol', '1'))
+    ('symbol', '2'))
+  * set:
+  <spanset+ 0:2>
+  0
+  1
+  2
+
+ but not beyond the boundary of alias expansion, because the resolution should
+ be made at the parsing stage
+
+  $ try --optimize '1^A' --config 'revsetalias.A=:2'
+  (parent
+    ('symbol', '1')
+    ('symbol', 'A'))
+  * expanded:
+  (parent
+    ('symbol', '1')
+    (rangepre
+      ('symbol', '2')))
+  * optimized:
+  (range
+    (parentpost
+      ('symbol', '1'))
+    ('symbol', '2'))
+  * set:
+  <spanset+ 0:2>
+  0
+  1
+  2
+BROKEN: should be parsed as '1^(:2)'
+
 ancestor can accept 0 or more arguments
 
   $ log 'ancestor()'