mercurial/encoding.py
changeset 22778 80f2b63dd83a
parent 22426 f6b533e64ed6
child 22779 d9585dda63c3
--- a/mercurial/encoding.py	Tue Sep 30 15:58:08 2014 -0700
+++ b/mercurial/encoding.py	Fri Oct 03 18:42:39 2014 -0700
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import error
+import error, parsers
 import unicodedata, locale, os
 
 def _getpreferredencoding():
@@ -258,6 +258,15 @@
             return concat(usub.encode(encoding))
     return ellipsis # no enough room for multi-column characters
 
+def asciilower(s):
+    '''convert a string to lowercase if ASCII
+
+    Raises UnicodeDecodeError if non-ASCII characters are found.'''
+    s.decode('ascii')
+    return s.lower()
+
+asciilower = getattr(parsers, 'asciilower', asciilower)
+
 def lower(s):
     "best-effort encoding-aware case-folding of local string s"
     try: