revset: stop lowercasing the regex pattern for 'author'
authorMatt Harbison <matt_harbison@yahoo.com>
Wed, 11 Jan 2017 22:42:10 -0500
changeset 30782 db38cfc7c29d
parent 30781 f2c069bf78ee
child 30783 931a60880df4
revset: stop lowercasing the regex pattern for 'author' It was probably unintentional for regex, as the meaning of some sequences like \S and \s is actually inverted by changing the case. For backward compatibility however, the matching is forced to case insensitive.
mercurial/revset.py
tests/test-revset.t
--- a/mercurial/revset.py	Thu Nov 24 18:45:29 2016 -0800
+++ b/mercurial/revset.py	Wed Jan 11 22:42:10 2017 -0500
@@ -556,9 +556,9 @@
     """Alias for ``user(string)``.
     """
     # i18n: "author" is a keyword
-    n = encoding.lower(getstring(x, _("author requires a string")))
-    kind, pattern, matcher = _substringmatcher(n)
-    return subset.filter(lambda x: matcher(encoding.lower(repo[x].user())),
+    n = getstring(x, _("author requires a string"))
+    kind, pattern, matcher = _substringmatcher(n, casesensitive=False)
+    return subset.filter(lambda x: matcher(repo[x].user()),
                          condrepr=('<user %r>', n))
 
 @predicate('bisect(string)', safe=True)
@@ -2249,10 +2249,15 @@
 
     return subset.filter(matches, condrepr=('<subrepo %r>', pat))
 
-def _substringmatcher(pattern):
-    kind, pattern, matcher = util.stringmatcher(pattern)
+def _substringmatcher(pattern, casesensitive=True):
+    kind, pattern, matcher = util.stringmatcher(pattern,
+                                                casesensitive=casesensitive)
     if kind == 'literal':
-        matcher = lambda s: pattern in s
+        if not casesensitive:
+            pattern = encoding.lower(pattern)
+            matcher = lambda s: pattern in encoding.lower(s)
+        else:
+            matcher = lambda s: pattern in s
     return kind, pattern, matcher
 
 @predicate('tag([name])', safe=True)
--- a/tests/test-revset.t	Thu Nov 24 18:45:29 2016 -0800
+++ b/tests/test-revset.t	Wed Jan 11 22:42:10 2017 -0500
@@ -865,6 +865,17 @@
   7
   8
   9
+  $ log 'author(r"re:\S")'
+  0
+  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
   $ log 'branch(é)'
   8
   9