Show More
@@ -463,6 +463,32 b' def revs(mctx, x):' | |||
|
463 | 463 | result.append(f) |
|
464 | 464 | return result |
|
465 | 465 | |
|
466 | @predicate('status(base, rev, pattern)') | |
|
467 | def status(mctx, x): | |
|
468 | """``status(base, rev, revspec)`` | |
|
469 | ||
|
470 | Evaluate predicate using status change between ``base`` and | |
|
471 | ``rev``. Examples: | |
|
472 | ||
|
473 | - ``status(3, 7, added())`` - matches files added from "3" to "7" | |
|
474 | """ | |
|
475 | repo = mctx.ctx.repo() | |
|
476 | # i18n: "status" is a keyword | |
|
477 | b, r, x = getargs(x, 3, 3, _("status takes three arguments")) | |
|
478 | # i18n: "status" is a keyword | |
|
479 | baseerr = _("first argument to status must be a revision") | |
|
480 | baserevspec = getstring(b, baseerr) | |
|
481 | if not baserevspec: | |
|
482 | raise error.ParseError(baseerr) | |
|
483 | reverr = _("second argument to status must be a revision") | |
|
484 | revspec = getstring(r, reverr) | |
|
485 | if not revspec: | |
|
486 | raise error.ParseError(reverr) | |
|
487 | basenode, node = scmutil.revpair(repo, [baserevspec, revspec]) | |
|
488 | basectx = repo[basenode] | |
|
489 | ctx = repo[node] | |
|
490 | return getset(mctx.switch(ctx, _buildstatus(ctx, x, basectx=basectx)), x) | |
|
491 | ||
|
466 | 492 | @predicate('subrepo([pattern])') |
|
467 | 493 | def subrepo(mctx, x): |
|
468 | 494 | """Subrepositories whose paths match the given pattern. |
@@ -538,6 +564,7 b' class fullmatchctx(matchctx):' | |||
|
538 | 564 | # filesets using matchctx.switch() |
|
539 | 565 | _switchcallers = [ |
|
540 | 566 | 'revs', |
|
567 | 'status', | |
|
541 | 568 | ] |
|
542 | 569 | |
|
543 | 570 | def _intree(funcs, tree): |
@@ -521,3 +521,101 b' overlapping set' | |||
|
521 | 521 | |
|
522 | 522 | $ fileset "revs('1+2', modified())" |
|
523 | 523 | b2 |
|
524 | ||
|
525 | test 'status(...)' | |
|
526 | ================= | |
|
527 | ||
|
528 | Simple case | |
|
529 | ----------- | |
|
530 | ||
|
531 | $ fileset "status(3, 4, added())" | |
|
532 | .hgsub | |
|
533 | .hgsubstate | |
|
534 | ||
|
535 | use rev to restrict matched file | |
|
536 | ----------------------------------------- | |
|
537 | ||
|
538 | $ hg status --removed --rev 0 --rev 1 | |
|
539 | R a2 | |
|
540 | $ fileset "status(0, 1, removed())" | |
|
541 | a2 | |
|
542 | $ fileset "* and status(0, 1, removed())" | |
|
543 | $ fileset -r 4 "status(0, 1, removed())" | |
|
544 | a2 | |
|
545 | $ fileset -r 4 "* and status(0, 1, removed())" | |
|
546 | $ fileset "revs('4', * and status(0, 1, removed()))" | |
|
547 | $ fileset "revs('0', * and status(0, 1, removed()))" | |
|
548 | a2 | |
|
549 | ||
|
550 | check wdir() | |
|
551 | ------------ | |
|
552 | ||
|
553 | $ hg status --removed --rev 4 | |
|
554 | R con.xml | |
|
555 | $ fileset "status(4, 'wdir()', removed())" | |
|
556 | con.xml | |
|
557 | ||
|
558 | $ hg status --removed --rev 2 | |
|
559 | R a2 | |
|
560 | $ fileset "status('2', 'wdir()', removed())" | |
|
561 | a2 | |
|
562 | ||
|
563 | test backward status | |
|
564 | -------------------- | |
|
565 | ||
|
566 | $ hg status --removed --rev 0 --rev 4 | |
|
567 | R a2 | |
|
568 | $ hg status --added --rev 4 --rev 0 | |
|
569 | A a2 | |
|
570 | $ fileset "status(4, 0, added())" | |
|
571 | a2 | |
|
572 | ||
|
573 | test cross branch status | |
|
574 | ------------------------ | |
|
575 | ||
|
576 | $ hg status --added --rev 1 --rev 2 | |
|
577 | A a2 | |
|
578 | $ fileset "status(1, 2, added())" | |
|
579 | a2 | |
|
580 | ||
|
581 | test with multi revs revset | |
|
582 | --------------------------- | |
|
583 | $ hg status --added --rev 0:1 --rev 3:4 | |
|
584 | A .hgsub | |
|
585 | A .hgsubstate | |
|
586 | A 1k | |
|
587 | A 2k | |
|
588 | A b2link | |
|
589 | A bin | |
|
590 | A c1 | |
|
591 | A con.xml | |
|
592 | $ fileset "status('0:1', '3:4', added())" | |
|
593 | .hgsub | |
|
594 | .hgsubstate | |
|
595 | 1k | |
|
596 | 2k | |
|
597 | b2link | |
|
598 | bin | |
|
599 | c1 | |
|
600 | con.xml | |
|
601 | ||
|
602 | tests with empty value | |
|
603 | ---------------------- | |
|
604 | ||
|
605 | Fully empty revset | |
|
606 | ||
|
607 | $ fileset "status('', '4', added())" | |
|
608 | hg: parse error: first argument to status must be a revision | |
|
609 | [255] | |
|
610 | $ fileset "status('2', '', added())" | |
|
611 | hg: parse error: second argument to status must be a revision | |
|
612 | [255] | |
|
613 | ||
|
614 | Empty revset will error at the revset layer | |
|
615 | ||
|
616 | $ fileset "status(' ', '4', added())" | |
|
617 | hg: parse error at 1: not a prefix: end | |
|
618 | [255] | |
|
619 | $ fileset "status('2', ' ', added())" | |
|
620 | hg: parse error at 1: not a prefix: end | |
|
621 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now