diff mercurial/revsetlang.py @ 31800:c63cb2d10d6d

revsetlang: enable optimization of 'x + y' expression It's been disabled since 4d1e56b29a91, but it can be enabled now as the ordering requirement is resolved at analyze().
author Yuya Nishihara <yuya@tcha.org>
date Sat, 14 May 2016 20:51:57 +0900
parents f3b151278655
children 11f501f0a213
line wrap: on
line diff
--- a/mercurial/revsetlang.py	Sat Apr 01 15:24:03 2017 -0700
+++ b/mercurial/revsetlang.py	Sat May 14 20:51:57 2016 +0900
@@ -434,9 +434,9 @@
         flushss()
         if len(ts) == 1:
             return ws[0], ts[0] # 'or' operation is fully optimized out
-        # we can't reorder trees by weight because it would change the order.
-        # ("sort(a + b)" == "sort(b + a)", but "a + b" != "b + a")
-        #   ts = tuple(t for w, t in sorted(zip(ws, ts), key=lambda wt: wt[0]))
+        if order != defineorder:
+            # reorder by weight only when f(a + b) == f(b + a)
+            ts = [wt[1] for wt in sorted(zip(ws, ts), key=lambda wt: wt[0])]
         return max(ws), (op, ('list',) + tuple(ts), order)
     elif op == 'not':
         # Optimize not public() to _notpublic() because we have a fast version