Mercurial > hg-stable
comparison tests/test-revset.t @ 33416:9467d5337292
revset: add experimental relation and subscript operators
The proposed syntax [1] was originally 'set{n rel}', but it seemed slightly
confusing if template is involved. On the other hand, we want to keep 'set[n]'
for future extension. So this patch introduces 'set#rel[n]' ternary operator.
I chose '#' just because it looks like applying an attribute.
This also adds stubs for 'set[n]' and 'set#rel' operators since these syntax
elements are fundamental for constructing 'set#rel[n]'.
[1]: https://www.mercurial-scm.org/wiki/RevsetOperatorPlan#ideas_from_mpm
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 08 Jul 2017 13:07:59 +0900 |
parents | 5d63e5f40bea |
children | d1b13d4995ed |
comparison
equal
deleted
inserted
replaced
33415:371f59c6a89e | 33416:9467d5337292 |
---|---|
498 None | 498 None |
499 any)) | 499 any)) |
500 hg: parse error: can't use a key-value pair in this context | 500 hg: parse error: can't use a key-value pair in this context |
501 [255] | 501 [255] |
502 | 502 |
503 relation-subscript operator has the highest binding strength (as function call): | |
504 | |
505 $ hg debugrevspec -p parsed 'tip:tip^#generations[-1]' | |
506 * parsed: | |
507 (range | |
508 ('symbol', 'tip') | |
509 (relsubscript | |
510 (parentpost | |
511 ('symbol', 'tip')) | |
512 ('symbol', 'generations') | |
513 (negate | |
514 ('symbol', '1')))) | |
515 hg: parse error: can't use a relation in this context | |
516 [255] | |
517 | |
518 $ hg debugrevspec -p parsed --no-show-revs 'not public()#generations[0]' | |
519 * parsed: | |
520 (not | |
521 (relsubscript | |
522 (func | |
523 ('symbol', 'public') | |
524 None) | |
525 ('symbol', 'generations') | |
526 ('symbol', '0'))) | |
527 hg: parse error: can't use a relation in this context | |
528 [255] | |
529 | |
530 left-hand side of relation-subscript operator should be optimized recursively: | |
531 | |
532 $ hg debugrevspec -p analyzed -p optimized --no-show-revs \ | |
533 > '(not public())#generations[0]' | |
534 * analyzed: | |
535 (relsubscript | |
536 (not | |
537 (func | |
538 ('symbol', 'public') | |
539 None | |
540 any) | |
541 define) | |
542 ('symbol', 'generations') | |
543 ('symbol', '0') | |
544 define) | |
545 * optimized: | |
546 (relsubscript | |
547 (func | |
548 ('symbol', '_notpublic') | |
549 None | |
550 any) | |
551 ('symbol', 'generations') | |
552 ('symbol', '0') | |
553 define) | |
554 hg: parse error: can't use a relation in this context | |
555 [255] | |
556 | |
557 resolution of subscript and relation-subscript ternary operators: | |
558 | |
559 $ hg debugrevspec -p analyzed 'tip[0]' | |
560 * analyzed: | |
561 (subscript | |
562 ('symbol', 'tip') | |
563 ('symbol', '0') | |
564 define) | |
565 hg: parse error: can't use a subscript in this context | |
566 [255] | |
567 | |
568 $ hg debugrevspec -p analyzed 'tip#rel[0]' | |
569 * analyzed: | |
570 (relsubscript | |
571 ('symbol', 'tip') | |
572 ('symbol', 'rel') | |
573 ('symbol', '0') | |
574 define) | |
575 hg: parse error: can't use a relation in this context | |
576 [255] | |
577 | |
578 $ hg debugrevspec -p analyzed '(tip#rel)[0]' | |
579 * analyzed: | |
580 (subscript | |
581 (relation | |
582 ('symbol', 'tip') | |
583 ('symbol', 'rel') | |
584 define) | |
585 ('symbol', '0') | |
586 define) | |
587 hg: parse error: can't use a subscript in this context | |
588 [255] | |
589 | |
590 $ hg debugrevspec -p analyzed 'tip#rel[0][1]' | |
591 * analyzed: | |
592 (subscript | |
593 (relsubscript | |
594 ('symbol', 'tip') | |
595 ('symbol', 'rel') | |
596 ('symbol', '0') | |
597 define) | |
598 ('symbol', '1') | |
599 define) | |
600 hg: parse error: can't use a subscript in this context | |
601 [255] | |
602 | |
603 $ hg debugrevspec -p analyzed 'tip#rel0#rel1[1]' | |
604 * analyzed: | |
605 (relsubscript | |
606 (relation | |
607 ('symbol', 'tip') | |
608 ('symbol', 'rel0') | |
609 define) | |
610 ('symbol', 'rel1') | |
611 ('symbol', '1') | |
612 define) | |
613 hg: parse error: can't use a relation in this context | |
614 [255] | |
615 | |
616 $ hg debugrevspec -p analyzed 'tip#rel0[0]#rel1[1]' | |
617 * analyzed: | |
618 (relsubscript | |
619 (relsubscript | |
620 ('symbol', 'tip') | |
621 ('symbol', 'rel0') | |
622 ('symbol', '0') | |
623 define) | |
624 ('symbol', 'rel1') | |
625 ('symbol', '1') | |
626 define) | |
627 hg: parse error: can't use a relation in this context | |
628 [255] | |
629 | |
630 parse errors of relation, subscript and relation-subscript operators: | |
631 | |
632 $ hg debugrevspec '[0]' | |
633 hg: parse error at 0: not a prefix: [ | |
634 [255] | |
635 $ hg debugrevspec '.#' | |
636 hg: parse error at 2: not a prefix: end | |
637 [255] | |
638 $ hg debugrevspec '#rel' | |
639 hg: parse error at 0: not a prefix: # | |
640 [255] | |
641 $ hg debugrevspec '.#rel[0' | |
642 hg: parse error at 7: unexpected token: end | |
643 [255] | |
644 $ hg debugrevspec '.]' | |
645 hg: parse error at 1: invalid token | |
646 [255] | |
647 | |
503 parsed tree at stages: | 648 parsed tree at stages: |
504 | 649 |
505 $ hg debugrevspec -p all '()' | 650 $ hg debugrevspec -p all '()' |
506 * parsed: | 651 * parsed: |
507 (group | 652 (group |