Show More
@@ -2072,15 +2072,20 methods = { | |||||
2072 | "parentpost": p1, |
|
2072 | "parentpost": p1, | |
2073 | } |
|
2073 | } | |
2074 |
|
2074 | |||
2075 |
def _ |
|
2075 | def _matchonly(revs, bases): | |
2076 | return ( |
|
2076 | """ | |
2077 | revs is not None |
|
2077 | >>> f = lambda *args: _matchonly(*map(parse, args)) | |
|
2078 | >>> f('ancestors(A)', 'not ancestors(B)') | |||
|
2079 | ('list', ('symbol', 'A'), ('symbol', 'B')) | |||
|
2080 | """ | |||
|
2081 | if (revs is not None | |||
2078 | and revs[0] == 'func' |
|
2082 | and revs[0] == 'func' | |
2079 | and getstring(revs[1], _('not a symbol')) == 'ancestors' |
|
2083 | and getstring(revs[1], _('not a symbol')) == 'ancestors' | |
2080 | and bases is not None |
|
2084 | and bases is not None | |
2081 | and bases[0] == 'not' |
|
2085 | and bases[0] == 'not' | |
2082 | and bases[1][0] == 'func' |
|
2086 | and bases[1][0] == 'func' | |
2083 | and getstring(bases[1][1], _('not a symbol')) == 'ancestors') |
|
2087 | and getstring(bases[1][1], _('not a symbol')) == 'ancestors'): | |
|
2088 | return ('list', revs[2], bases[1][2]) | |||
2084 |
|
2089 | |||
2085 | def optimize(x, small): |
|
2090 | def optimize(x, small): | |
2086 | if x is None: |
|
2091 | if x is None: | |
@@ -2119,10 +2124,9 def optimize(x, small): | |||||
2119 | w = min(wa, wb) |
|
2124 | w = min(wa, wb) | |
2120 |
|
2125 | |||
2121 | # (::x and not ::y)/(not ::y and ::x) have a fast path |
|
2126 | # (::x and not ::y)/(not ::y and ::x) have a fast path | |
2122 | if _isonly(ta, tb): |
|
2127 | tm = _matchonly(ta, tb) or _matchonly(tb, ta) | |
2123 | return w, ('func', ('symbol', 'only'), ('list', ta[2], tb[1][2])) |
|
2128 | if tm: | |
2124 | if _isonly(tb, ta): |
|
2129 | return w, ('func', ('symbol', 'only'), tm) | |
2125 | return w, ('func', ('symbol', 'only'), ('list', tb[2], ta[1][2])) |
|
|||
2126 |
|
2130 | |||
2127 | if tb is not None and tb[0] == 'not': |
|
2131 | if tb is not None and tb[0] == 'not': | |
2128 | return wa, ('difference', ta, tb[1]) |
|
2132 | return wa, ('difference', ta, tb[1]) |
General Comments 0
You need to be logged in to leave comments.
Login now