mercurial/revset.py
changeset 30783 931a60880df4
parent 30782 db38cfc7c29d
child 30784 5dd67f0993ce
--- a/mercurial/revset.py	Wed Jan 11 22:42:10 2017 -0500
+++ b/mercurial/revset.py	Sat Jan 07 21:26:32 2017 -0500
@@ -814,15 +814,18 @@
 @predicate('desc(string)', safe=True)
 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:`.
     """
     # i18n: "desc" is a keyword
-    ds = encoding.lower(getstring(x, _("desc requires a string")))
-
-    def matches(x):
-        c = repo[x]
-        return ds in encoding.lower(c.description())
-
-    return subset.filter(matches, condrepr=('<desc %r>', ds))
+    ds = getstring(x, _("desc requires a string"))
+
+    kind, pattern, matcher = _substringmatcher(ds, casesensitive=False)
+
+    return subset.filter(lambda r: matcher(repo[r].description()),
+                         condrepr=('<desc %r>', ds))
 
 def _descendants(repo, subset, x, followfirst=False):
     roots = getset(repo, fullreposet(repo), x)