Patchwork [3,of,4] revset: introduce temporary variables in optimize() where they look better

login
register
mail settings
Submitter Yuya Nishihara
Date May 5, 2016, 7:57 a.m.
Message ID <623d1c438bfe30c0937c.1462435054@mimosa>
Download mbox | patch
Permalink /patch/14906/
State Accepted
Headers show

Comments

Yuya Nishihara - May 5, 2016, 7:57 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1462160829 -32400
#      Mon May 02 12:47:09 2016 +0900
# Node ID 623d1c438bfe30c0937cb16f7a1873f22e6ae4a0
# Parent  8c9a75f74134dcb4479a873ad7208add62075704
revset: introduce temporary variables in optimize() where they look better

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2100,8 +2100,8 @@  def optimize(x, small):
     if op == 'minus':
         return optimize(('and', x[1], ('not', x[2])), small)
     elif op == 'only':
-        return optimize(('func', ('symbol', 'only'),
-                         ('list', x[1], x[2])), small)
+        t = ('func', ('symbol', 'only'), ('list', x[1], x[2]))
+        return optimize(t, small)
     elif op == 'onlypost':
         return optimize(('func', ('symbol', 'only'), x[1]), small)
     elif op == 'dagrangepre':
@@ -2115,8 +2115,8 @@  def optimize(x, small):
     elif op == 'rangepost':
         return optimize(('range', x[1], ('string', 'tip')), small)
     elif op == 'negate':
-        return optimize(('string',
-                         '-' + getstring(x[1], _("can't negate that"))), small)
+        s = getstring(x[1], _("can't negate that"))
+        return optimize(('string', '-' + s), small)
     elif op in 'string symbol negate':
         return smallbonus, x # single revisions are small
     elif op == 'and':