changeset 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 301512fd6852
files mercurial/help/revisions.txt mercurial/revset.py
diffstat 2 files changed, 30 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help/revisions.txt	Sat Jan 07 21:26:32 2017 -0500
+++ b/mercurial/help/revisions.txt	Sat Jan 07 23:35:35 2017 -0500
@@ -119,6 +119,23 @@
 ``x^``
   Equivalent to ``x^1``, the first parent of each changeset in x.
 
+Patterns
+========
+
+Where noted, predicates that perform string matching can accept a pattern
+string. The pattern may be either a literal, or a regular expression. If the
+pattern starts with ``re:``, the remainder of the pattern is treated as a
+regular expression. Otherwise, it is treated as a literal. To match a pattern
+that actually starts with ``re:``, use the prefix ``literal:``.
+
+Matching is case-sensitive, unless otherwise noted.  To perform a case-
+insensitive match on a case-sensitive predicate, use a regular expression,
+prefixed with ``(?i)``.
+
+  For example::
+
+    ``tag(r're:(?i)release')`` matches "release" or "RELEASE" or "Release", etc
+
 Predicates
 ==========
 
--- a/mercurial/revset.py	Sat Jan 07 21:26:32 2017 -0500
+++ b/mercurial/revset.py	Sat Jan 07 23:35:35 2017 -0500
@@ -588,9 +588,7 @@
 def bookmark(repo, subset, x):
     """The named bookmark or all bookmarks.
 
-    If `name` starts with `re:`, the remainder of the name is treated as
-    a regular expression. To match a bookmark that actually starts with `re:`,
-    use the prefix `literal:`.
+    Pattern matching is supported for `name`. See ``hg help revsets.patterns``.
     """
     # i18n: "bookmark" is a keyword
     args = getargs(x, 0, 1, _('bookmark takes one or no arguments'))
@@ -628,9 +626,8 @@
     All changesets belonging to the given branch or the branches of the given
     changesets.
 
-    If `string` starts with `re:`, the remainder of the name is treated as
-    a regular expression. To match a branch that actually starts with `re:`,
-    use the prefix `literal:`.
+    Pattern matching is supported for `string`. See
+    ``hg help revsets.patterns``.
     """
     getbi = repo.revbranchcache().branchinfo
 
@@ -815,9 +812,8 @@
 def desc(repo, subset, x):
     """Search commit message for string. The match is case-insensitive.
 
-    If `string` starts with `re:`, the remainder of the string is treated as
-    a regular expression. To match a substring that actually starts with `re:`,
-    use the prefix `literal:`.
+    Pattern matching is supported for `string`. See
+    ``hg help revsets.patterns``.
     """
     # i18n: "desc" is a keyword
     ds = getstring(x, _("desc requires a string"))
@@ -927,9 +923,8 @@
     """Changesets with the given label in the extra metadata, with the given
     optional value.
 
-    If `value` starts with `re:`, the remainder of the value is treated as
-    a regular expression. To match a value that actually starts with `re:`,
-    use the prefix `literal:`.
+    Pattern matching is supported for `value`. See
+    ``hg help revsets.patterns``.
     """
     args = getargsdict(x, 'extra', 'label value')
     if 'label' not in args:
@@ -1409,9 +1404,8 @@
 def named(repo, subset, x):
     """The changesets in a given namespace.
 
-    If `namespace` starts with `re:`, the remainder of the string is treated as
-    a regular expression. To match a namespace that actually starts with `re:`,
-    use the prefix `literal:`.
+    Pattern matching is supported for `namespace`. See
+    ``hg help revsets.patterns``.
     """
     # i18n: "named" is a keyword
     args = getargs(x, 1, 1, _('named requires a namespace argument'))
@@ -2267,9 +2261,8 @@
 def tag(repo, subset, x):
     """The specified tag by name, or all tagged revisions if no name is given.
 
-    If `name` starts with `re:`, the remainder of the name is treated as
-    a regular expression. To match a tag that actually starts with `re:`,
-    use the prefix `literal:`.
+    Pattern matching is supported for `name`. See
+    ``hg help revsets.patterns``.
     """
     # i18n: "tag" is a keyword
     args = getargs(x, 0, 1, _("tag takes one or no arguments"))
@@ -2310,9 +2303,8 @@
 def user(repo, subset, x):
     """User name contains string. The match is case-insensitive.
 
-    If `string` starts with `re:`, the remainder of the string is treated as
-    a regular expression. To match a user that actually contains `re:`, use
-    the prefix `literal:`.
+    Pattern matching is supported for `string`. See
+    ``hg help revsets.patterns``.
     """
     return author(repo, subset, x)