Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 30784:5dd67f0993ce
help: eliminate duplicate text for revset string patterns
There's no reason to duplicate this so many times, and it's likely an instance
will be missed if support for a new pattern is added and documented. The
stringmatcher is mostly used by revsets, though it is also used for the 'tag'
related templates, and namespace filtering in the journal extension. So maybe
there's a better place to document it. `hg help patterns` seems inappropriate,
because that is all file pattern matching.
While here, indicate how to perform case insensitive regex searches.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 07 Jan 2017 23:35:35 -0500 |
parents | 931a60880df4 |
children | 0b49449a01f4 |
comparison
equal
deleted
inserted
replaced
30783:931a60880df4 | 30784:5dd67f0993ce |
---|---|
586 | 586 |
587 @predicate('bookmark([name])', safe=True) | 587 @predicate('bookmark([name])', safe=True) |
588 def bookmark(repo, subset, x): | 588 def bookmark(repo, subset, x): |
589 """The named bookmark or all bookmarks. | 589 """The named bookmark or all bookmarks. |
590 | 590 |
591 If `name` starts with `re:`, the remainder of the name is treated as | 591 Pattern matching is supported for `name`. See ``hg help revsets.patterns``. |
592 a regular expression. To match a bookmark that actually starts with `re:`, | |
593 use the prefix `literal:`. | |
594 """ | 592 """ |
595 # i18n: "bookmark" is a keyword | 593 # i18n: "bookmark" is a keyword |
596 args = getargs(x, 0, 1, _('bookmark takes one or no arguments')) | 594 args = getargs(x, 0, 1, _('bookmark takes one or no arguments')) |
597 if args: | 595 if args: |
598 bm = getstring(args[0], | 596 bm = getstring(args[0], |
626 def branch(repo, subset, x): | 624 def branch(repo, subset, x): |
627 """ | 625 """ |
628 All changesets belonging to the given branch or the branches of the given | 626 All changesets belonging to the given branch or the branches of the given |
629 changesets. | 627 changesets. |
630 | 628 |
631 If `string` starts with `re:`, the remainder of the name is treated as | 629 Pattern matching is supported for `string`. See |
632 a regular expression. To match a branch that actually starts with `re:`, | 630 ``hg help revsets.patterns``. |
633 use the prefix `literal:`. | |
634 """ | 631 """ |
635 getbi = repo.revbranchcache().branchinfo | 632 getbi = repo.revbranchcache().branchinfo |
636 | 633 |
637 try: | 634 try: |
638 b = getstring(x, '') | 635 b = getstring(x, '') |
813 | 810 |
814 @predicate('desc(string)', safe=True) | 811 @predicate('desc(string)', safe=True) |
815 def desc(repo, subset, x): | 812 def desc(repo, subset, x): |
816 """Search commit message for string. The match is case-insensitive. | 813 """Search commit message for string. The match is case-insensitive. |
817 | 814 |
818 If `string` starts with `re:`, the remainder of the string is treated as | 815 Pattern matching is supported for `string`. See |
819 a regular expression. To match a substring that actually starts with `re:`, | 816 ``hg help revsets.patterns``. |
820 use the prefix `literal:`. | |
821 """ | 817 """ |
822 # i18n: "desc" is a keyword | 818 # i18n: "desc" is a keyword |
823 ds = getstring(x, _("desc requires a string")) | 819 ds = getstring(x, _("desc requires a string")) |
824 | 820 |
825 kind, pattern, matcher = _substringmatcher(ds, casesensitive=False) | 821 kind, pattern, matcher = _substringmatcher(ds, casesensitive=False) |
925 @predicate('extra(label, [value])', safe=True) | 921 @predicate('extra(label, [value])', safe=True) |
926 def extra(repo, subset, x): | 922 def extra(repo, subset, x): |
927 """Changesets with the given label in the extra metadata, with the given | 923 """Changesets with the given label in the extra metadata, with the given |
928 optional value. | 924 optional value. |
929 | 925 |
930 If `value` starts with `re:`, the remainder of the value is treated as | 926 Pattern matching is supported for `value`. See |
931 a regular expression. To match a value that actually starts with `re:`, | 927 ``hg help revsets.patterns``. |
932 use the prefix `literal:`. | |
933 """ | 928 """ |
934 args = getargsdict(x, 'extra', 'label value') | 929 args = getargsdict(x, 'extra', 'label value') |
935 if 'label' not in args: | 930 if 'label' not in args: |
936 # i18n: "extra" is a keyword | 931 # i18n: "extra" is a keyword |
937 raise error.ParseError(_('extra takes at least 1 argument')) | 932 raise error.ParseError(_('extra takes at least 1 argument')) |
1407 | 1402 |
1408 @predicate('named(namespace)') | 1403 @predicate('named(namespace)') |
1409 def named(repo, subset, x): | 1404 def named(repo, subset, x): |
1410 """The changesets in a given namespace. | 1405 """The changesets in a given namespace. |
1411 | 1406 |
1412 If `namespace` starts with `re:`, the remainder of the string is treated as | 1407 Pattern matching is supported for `namespace`. See |
1413 a regular expression. To match a namespace that actually starts with `re:`, | 1408 ``hg help revsets.patterns``. |
1414 use the prefix `literal:`. | |
1415 """ | 1409 """ |
1416 # i18n: "named" is a keyword | 1410 # i18n: "named" is a keyword |
1417 args = getargs(x, 1, 1, _('named requires a namespace argument')) | 1411 args = getargs(x, 1, 1, _('named requires a namespace argument')) |
1418 | 1412 |
1419 ns = getstring(args[0], | 1413 ns = getstring(args[0], |
2265 | 2259 |
2266 @predicate('tag([name])', safe=True) | 2260 @predicate('tag([name])', safe=True) |
2267 def tag(repo, subset, x): | 2261 def tag(repo, subset, x): |
2268 """The specified tag by name, or all tagged revisions if no name is given. | 2262 """The specified tag by name, or all tagged revisions if no name is given. |
2269 | 2263 |
2270 If `name` starts with `re:`, the remainder of the name is treated as | 2264 Pattern matching is supported for `name`. See |
2271 a regular expression. To match a tag that actually starts with `re:`, | 2265 ``hg help revsets.patterns``. |
2272 use the prefix `literal:`. | |
2273 """ | 2266 """ |
2274 # i18n: "tag" is a keyword | 2267 # i18n: "tag" is a keyword |
2275 args = getargs(x, 0, 1, _("tag takes one or no arguments")) | 2268 args = getargs(x, 0, 1, _("tag takes one or no arguments")) |
2276 cl = repo.changelog | 2269 cl = repo.changelog |
2277 if args: | 2270 if args: |
2308 | 2301 |
2309 @predicate('user(string)', safe=True) | 2302 @predicate('user(string)', safe=True) |
2310 def user(repo, subset, x): | 2303 def user(repo, subset, x): |
2311 """User name contains string. The match is case-insensitive. | 2304 """User name contains string. The match is case-insensitive. |
2312 | 2305 |
2313 If `string` starts with `re:`, the remainder of the string is treated as | 2306 Pattern matching is supported for `string`. See |
2314 a regular expression. To match a user that actually contains `re:`, use | 2307 ``hg help revsets.patterns``. |
2315 the prefix `literal:`. | |
2316 """ | 2308 """ |
2317 return author(repo, subset, x) | 2309 return author(repo, subset, x) |
2318 | 2310 |
2319 @predicate('wdir', safe=True) | 2311 @predicate('wdir', safe=True) |
2320 def wdir(repo, subset, x): | 2312 def wdir(repo, subset, x): |