mercurial/revset.py
changeset 16823 b23bacb230c9
parent 16822 da55d8a77390
child 16824 f3b8c82a559c
--- a/mercurial/revset.py	Wed May 30 23:13:33 2012 +0100
+++ b/mercurial/revset.py	Wed May 30 23:13:58 2012 +0100
@@ -279,7 +279,8 @@
     """
     # i18n: "author" is a keyword
     n = encoding.lower(getstring(x, _("author requires a string")))
-    return [r for r in subset if n in encoding.lower(repo[r].user())]
+    kind, pattern, matcher = _substringmatcher(n)
+    return [r for r in subset if matcher(encoding.lower(repo[r].user()))]
 
 def bisect(repo, subset, x):
     """``bisect(string)``
@@ -1188,6 +1189,11 @@
         pattern = pattern[8:]
     return 'literal', pattern, pattern.__eq__
 
+def _substringmatcher(pattern):
+    kind, pattern, matcher = _stringmatcher(pattern)
+    if kind == 'literal':
+        matcher = lambda s: pattern in s
+    return kind, pattern, matcher
 
 def tag(repo, subset, x):
     """``tag([name])``
@@ -1219,6 +1225,10 @@
 def user(repo, subset, x):
     """``user(string)``
     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:`.
     """
     return author(repo, subset, x)