mercurial/revset.py
changeset 20499 2efd608473fb
parent 20498 fb2df4506c87
child 20512 659b8d8ddf19
equal deleted inserted replaced
20498:fb2df4506c87 20499:2efd608473fb
  1747     elif op in 'string symbol negate':
  1747     elif op in 'string symbol negate':
  1748         return smallbonus, x # single revisions are small
  1748         return smallbonus, x # single revisions are small
  1749     elif op == 'and':
  1749     elif op == 'and':
  1750         wa, ta = optimize(x[1], True)
  1750         wa, ta = optimize(x[1], True)
  1751         wb, tb = optimize(x[2], True)
  1751         wb, tb = optimize(x[2], True)
       
  1752 
       
  1753         # (::x and not ::y)/(not ::y and ::x) have a fast path
       
  1754         def ismissingancestors(revs, bases):
       
  1755             return (
       
  1756                 revs[0] == 'func'
       
  1757                 and getstring(revs[1], _('not a symbol')) == 'ancestors'
       
  1758                 and bases[0] == 'not'
       
  1759                 and bases[1][0] == 'func'
       
  1760                 and getstring(bases[1][1], _('not a symbol')) == 'ancestors')
       
  1761 
  1752         w = min(wa, wb)
  1762         w = min(wa, wb)
       
  1763         if ismissingancestors(ta, tb):
       
  1764             return w, ('func', ('symbol', '_missingancestors'),
       
  1765                        ('list', ta[2], tb[1][2]))
       
  1766         if ismissingancestors(tb, ta):
       
  1767             return w, ('func', ('symbol', '_missingancestors'),
       
  1768                        ('list', tb[2], ta[1][2]))
       
  1769 
  1753         if wa > wb:
  1770         if wa > wb:
  1754             return w, (op, tb, ta)
  1771             return w, (op, tb, ta)
  1755         return w, (op, ta, tb)
  1772         return w, (op, ta, tb)
  1756     elif op == 'or':
  1773     elif op == 'or':
  1757         wa, ta = optimize(x[1], False)
  1774         wa, ta = optimize(x[1], False)