changeset 14842:805651777188 stable

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.
author Matt Mackall <mpm@selenic.com>
date Wed, 06 Jul 2011 13:37:50 -0500
parents 6990340c57a8
children e9264b45237d
files mercurial/revset.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)