comparison mercurial/revset.py @ 16823:b23bacb230c9

revset: add pattern matching to the 'user' revset expression
author Simon King <simon@simonking.org.uk>
date Wed, 30 May 2012 23:13:58 +0100
parents da55d8a77390
children f3b8c82a559c
comparison
equal deleted inserted replaced
16822:da55d8a77390 16823:b23bacb230c9
277 """``author(string)`` 277 """``author(string)``
278 Alias for ``user(string)``. 278 Alias for ``user(string)``.
279 """ 279 """
280 # i18n: "author" is a keyword 280 # i18n: "author" is a keyword
281 n = encoding.lower(getstring(x, _("author requires a string"))) 281 n = encoding.lower(getstring(x, _("author requires a string")))
282 return [r for r in subset if n in encoding.lower(repo[r].user())] 282 kind, pattern, matcher = _substringmatcher(n)
283 return [r for r in subset if matcher(encoding.lower(repo[r].user()))]
283 284
284 def bisect(repo, subset, x): 285 def bisect(repo, subset, x):
285 """``bisect(string)`` 286 """``bisect(string)``
286 Changesets marked in the specified bisect status: 287 Changesets marked in the specified bisect status:
287 288
1186 return 're', pattern, regex.search 1187 return 're', pattern, regex.search
1187 elif pattern.startswith('literal:'): 1188 elif pattern.startswith('literal:'):
1188 pattern = pattern[8:] 1189 pattern = pattern[8:]
1189 return 'literal', pattern, pattern.__eq__ 1190 return 'literal', pattern, pattern.__eq__
1190 1191
1192 def _substringmatcher(pattern):
1193 kind, pattern, matcher = _stringmatcher(pattern)
1194 if kind == 'literal':
1195 matcher = lambda s: pattern in s
1196 return kind, pattern, matcher
1191 1197
1192 def tag(repo, subset, x): 1198 def tag(repo, subset, x):
1193 """``tag([name])`` 1199 """``tag([name])``
1194 The specified tag by name, or all tagged revisions if no name is given. 1200 The specified tag by name, or all tagged revisions if no name is given.
1195 """ 1201 """
1217 return tag(repo, subset, x) 1223 return tag(repo, subset, x)
1218 1224
1219 def user(repo, subset, x): 1225 def user(repo, subset, x):
1220 """``user(string)`` 1226 """``user(string)``
1221 User name contains string. The match is case-insensitive. 1227 User name contains string. The match is case-insensitive.
1228
1229 If `string` starts with `re:`, the remainder of the string is treated as
1230 a regular expression. To match a user that actually contains `re:`, use
1231 the prefix `literal:`.
1222 """ 1232 """
1223 return author(repo, subset, x) 1233 return author(repo, subset, x)
1224 1234
1225 # for internal use 1235 # for internal use
1226 def _list(repo, subset, x): 1236 def _list(repo, subset, x):