Show More
@@ -1749,7 +1749,24 b' def optimize(x, 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) |
@@ -444,6 +444,70 b' ancestor can accept 0 or more arguments' | |||||
444 | $ log 'tag(tip)' |
|
444 | $ log 'tag(tip)' | |
445 | 9 |
|
445 | 9 | |
446 |
|
446 | |||
|
447 | check that conversion to _missingancestors works | |||
|
448 | $ try --optimize '::3 - ::1' | |||
|
449 | (minus | |||
|
450 | (dagrangepre | |||
|
451 | ('symbol', '3')) | |||
|
452 | (dagrangepre | |||
|
453 | ('symbol', '1'))) | |||
|
454 | * optimized: | |||
|
455 | (func | |||
|
456 | ('symbol', '_missingancestors') | |||
|
457 | (list | |||
|
458 | ('symbol', '3') | |||
|
459 | ('symbol', '1'))) | |||
|
460 | 3 | |||
|
461 | $ try --optimize 'ancestors(1) - ancestors(3)' | |||
|
462 | (minus | |||
|
463 | (func | |||
|
464 | ('symbol', 'ancestors') | |||
|
465 | ('symbol', '1')) | |||
|
466 | (func | |||
|
467 | ('symbol', 'ancestors') | |||
|
468 | ('symbol', '3'))) | |||
|
469 | * optimized: | |||
|
470 | (func | |||
|
471 | ('symbol', '_missingancestors') | |||
|
472 | (list | |||
|
473 | ('symbol', '1') | |||
|
474 | ('symbol', '3'))) | |||
|
475 | $ try --optimize 'not ::2 and ::6' | |||
|
476 | (and | |||
|
477 | (not | |||
|
478 | (dagrangepre | |||
|
479 | ('symbol', '2'))) | |||
|
480 | (dagrangepre | |||
|
481 | ('symbol', '6'))) | |||
|
482 | * optimized: | |||
|
483 | (func | |||
|
484 | ('symbol', '_missingancestors') | |||
|
485 | (list | |||
|
486 | ('symbol', '6') | |||
|
487 | ('symbol', '2'))) | |||
|
488 | 3 | |||
|
489 | 4 | |||
|
490 | 5 | |||
|
491 | 6 | |||
|
492 | $ try --optimize 'ancestors(6) and not ancestors(4)' | |||
|
493 | (and | |||
|
494 | (func | |||
|
495 | ('symbol', 'ancestors') | |||
|
496 | ('symbol', '6')) | |||
|
497 | (not | |||
|
498 | (func | |||
|
499 | ('symbol', 'ancestors') | |||
|
500 | ('symbol', '4')))) | |||
|
501 | * optimized: | |||
|
502 | (func | |||
|
503 | ('symbol', '_missingancestors') | |||
|
504 | (list | |||
|
505 | ('symbol', '6') | |||
|
506 | ('symbol', '4'))) | |||
|
507 | 3 | |||
|
508 | 5 | |||
|
509 | 6 | |||
|
510 | ||||
447 | we can use patterns when searching for tags |
|
511 | we can use patterns when searching for tags | |
448 |
|
512 | |||
449 | $ log 'tag("1..*")' |
|
513 | $ log 'tag("1..*")' |
General Comments 0
You need to be logged in to leave comments.
Login now