comparison mercurial/revset.py @ 15726:9b822edecb4c

i18n: use "encoding.lower()" to normalize specified string for revset some problematic encoding (e.g.: cp932) uses ASCII alphabet characters in byte sequence of multi byte characters. "str.lower()" on such byte sequence may treat distinct characters as same one, and cause unexpected log matching. this patch uses "encoding.lower()" instead of "str.lower()" to normalize strings for compare.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sun, 25 Dec 2011 20:35:16 +0900
parents 2555f441a32f
children a814f8fcc65a
comparison
equal deleted inserted replaced
15725:988409e44a76 15726:9b822edecb4c
9 import parser, util, error, discovery, hbisect 9 import parser, util, error, discovery, hbisect
10 import node as nodemod 10 import node as nodemod
11 import bookmarks as bookmarksmod 11 import bookmarks as bookmarksmod
12 import match as matchmod 12 import match as matchmod
13 from i18n import _ 13 from i18n import _
14 import encoding
14 15
15 elements = { 16 elements = {
16 "(": (20, ("group", 1, ")"), ("func", 1, ")")), 17 "(": (20, ("group", 1, ")"), ("func", 1, ")")),
17 "~": (18, None, ("ancestor", 18)), 18 "~": (18, None, ("ancestor", 18)),
18 "^": (18, None, ("parent", 18), ("parentpost", 18)), 19 "^": (18, None, ("parent", 18), ("parentpost", 18)),
231 def author(repo, subset, x): 232 def author(repo, subset, x):
232 """``author(string)`` 233 """``author(string)``
233 Alias for ``user(string)``. 234 Alias for ``user(string)``.
234 """ 235 """
235 # i18n: "author" is a keyword 236 # i18n: "author" is a keyword
236 n = getstring(x, _("author requires a string")).lower() 237 n = encoding.lower(getstring(x, _("author requires a string")))
237 return [r for r in subset if n in repo[r].user().lower()] 238 return [r for r in subset if n in encoding.lower(repo[r].user())]
238 239
239 def bisect(repo, subset, x): 240 def bisect(repo, subset, x):
240 """``bisect(string)`` 241 """``bisect(string)``
241 Changesets marked in the specified bisect status: 242 Changesets marked in the specified bisect status:
242 243
374 def desc(repo, subset, x): 375 def desc(repo, subset, x):
375 """``desc(string)`` 376 """``desc(string)``
376 Search commit message for string. The match is case-insensitive. 377 Search commit message for string. The match is case-insensitive.
377 """ 378 """
378 # i18n: "desc" is a keyword 379 # i18n: "desc" is a keyword
379 ds = getstring(x, _("desc requires a string")).lower() 380 ds = encoding.lower(getstring(x, _("desc requires a string")))
380 l = [] 381 l = []
381 for r in subset: 382 for r in subset:
382 c = repo[r] 383 c = repo[r]
383 if ds in c.description().lower(): 384 if ds in encoding.lower(c.description()):
384 l.append(r) 385 l.append(r)
385 return l 386 return l
386 387
387 def descendants(repo, subset, x): 388 def descendants(repo, subset, x):
388 """``descendants(set)`` 389 """``descendants(set)``
520 """``keyword(string)`` 521 """``keyword(string)``
521 Search commit message, user name, and names of changed files for 522 Search commit message, user name, and names of changed files for
522 string. The match is case-insensitive. 523 string. The match is case-insensitive.
523 """ 524 """
524 # i18n: "keyword" is a keyword 525 # i18n: "keyword" is a keyword
525 kw = getstring(x, _("keyword requires a string")).lower() 526 kw = encoding.lower(getstring(x, _("keyword requires a string")))
526 l = [] 527 l = []
527 for r in subset: 528 for r in subset:
528 c = repo[r] 529 c = repo[r]
529 t = " ".join(c.files() + [c.user(), c.description()]) 530 t = " ".join(c.files() + [c.user(), c.description()])
530 if kw in t.lower(): 531 if kw in encoding.lower(t):
531 l.append(r) 532 l.append(r)
532 return l 533 return l
533 534
534 def limit(repo, subset, x): 535 def limit(repo, subset, x):
535 """``limit(set, [n])`` 536 """``limit(set, [n])``