revsets: do the right thing with x^:y (issue2884) stable
authorMatt Mackall <mpm@selenic.com>
Wed, 06 Jul 2011 13:37:50 -0500
branchstable
changeset 14842 805651777188
parent 14841 6990340c57a8
child 14843 e9264b45237d
revsets: do the right thing with x^:y (issue2884) Given an operator ^ that's either postfix or infix and an operator : that's either prefix or infix, the parser can't figure out the right thing to do. So we rewrite the expression to be sensible in the optimizer.
mercurial/revset.py
--- a/mercurial/revset.py	Wed Jul 06 18:28:42 2011 +0900
+++ b/mercurial/revset.py	Wed Jul 06 13:37:50 2011 -0500
@@ -928,6 +928,14 @@
     elif op == 'group':
         return optimize(x[1], small)
     elif op in 'range list parent ancestorspec':
+        if op == 'parent':
+            # x^:y means (x^) : y, not x ^ (:y)
+            post = ('parentpost', x[1])
+            if x[2][0] == 'dagrangepre':
+                return optimize(('dagrange', post, x[2][1]), small)
+            elif x[2][0] == 'rangepre':
+                return optimize(('range', post, x[2][1]), small)
+
         wa, ta = optimize(x[1], small)
         wb, tb = optimize(x[2], small)
         return wa + wb, (op, ta, tb)