# HG changeset patch
# User Matt Harbison <matt_harbi...@yahoo.com>
# Date 1483850135 18000
#      Sat Jan 07 23:35:35 2017 -0500
# Node ID 2060486431053a99eafa4234aea139f6a31dc2d7
# Parent  29cbe16c5cccf600fae928df52dbd44171096a6f
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.

diff --git a/mercurial/help/revsets.txt b/mercurial/help/revsets.txt
--- a/mercurial/help/revsets.txt
+++ b/mercurial/help/revsets.txt
@@ -79,6 +79,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 tags containing "release" or "RELEASE".
+
 Predicates
 ==========
 
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -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)
 
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to