Show More
@@ -17,7 +17,8 b' from demandload import *' | |||||
17 | demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") |
|
17 | demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile") | |
18 | demandload(globals(), "os threading time calendar ConfigParser locale") |
|
18 | demandload(globals(), "os threading time calendar ConfigParser locale") | |
19 |
|
19 | |||
20 | _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() |
|
20 | _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() \ | |
|
21 | or "ascii" | |||
21 | _encodingmode = os.environ.get("HGENCODINGMODE", "strict") |
|
22 | _encodingmode = os.environ.get("HGENCODINGMODE", "strict") | |
22 | _fallbackencoding = 'ISO-8859-1' |
|
23 | _fallbackencoding = 'ISO-8859-1' | |
23 |
|
24 | |||
@@ -35,6 +36,8 b' def tolocal(s):' | |||||
35 | try: |
|
36 | try: | |
36 | u = s.decode(e) # attempt strict decoding |
|
37 | u = s.decode(e) # attempt strict decoding | |
37 | return u.encode(_encoding, "replace") |
|
38 | return u.encode(_encoding, "replace") | |
|
39 | except LookupError, k: | |||
|
40 | raise Abort(_("%s, please check your locale settings") % k) | |||
38 | except UnicodeDecodeError: |
|
41 | except UnicodeDecodeError: | |
39 | pass |
|
42 | pass | |
40 | u = s.decode("utf-8", "replace") # last ditch |
|
43 | u = s.decode("utf-8", "replace") # last ditch | |
@@ -54,7 +57,9 b' def fromlocal(s):' | |||||
54 | return s.decode(_encoding, _encodingmode).encode("utf-8") |
|
57 | return s.decode(_encoding, _encodingmode).encode("utf-8") | |
55 | except UnicodeDecodeError, inst: |
|
58 | except UnicodeDecodeError, inst: | |
56 | sub = s[max(0, inst.start-10):inst.start+10] |
|
59 | sub = s[max(0, inst.start-10):inst.start+10] | |
57 |
raise Abort("decoding near '%s': %s! |
|
60 | raise Abort("decoding near '%s': %s!" % (sub, inst)) | |
|
61 | except LookupError, k: | |||
|
62 | raise Abort(_("%s, please check your locale settings") % k) | |||
58 |
|
63 | |||
59 | def locallen(s): |
|
64 | def locallen(s): | |
60 | """Find the length in characters of a local string""" |
|
65 | """Find the length in characters of a local string""" | |
@@ -70,7 +75,7 b' def localsub(s, a, b=None):' | |||||
70 | return u.encode(_encoding, _encodingmode) |
|
75 | return u.encode(_encoding, _encodingmode) | |
71 | except UnicodeDecodeError, inst: |
|
76 | except UnicodeDecodeError, inst: | |
72 | sub = s[max(0, inst.start-10), inst.start+10] |
|
77 | sub = s[max(0, inst.start-10), inst.start+10] | |
73 | raise Abort("decoding near '%s': %s!\n" % (sub, inst)) |
|
78 | raise Abort(_("decoding near '%s': %s!\n") % (sub, inst)) | |
74 |
|
79 | |||
75 | # used by parsedate |
|
80 | # used by parsedate | |
76 | defaultdateformats = ( |
|
81 | defaultdateformats = ( |
@@ -52,3 +52,5 b" echo '[ui]' >> .hg/hgrc" | |||||
52 | echo 'fallbackencoding = koi8-r' >> .hg/hgrc |
|
52 | echo 'fallbackencoding = koi8-r' >> .hg/hgrc | |
53 | echo % utf-8 |
|
53 | echo % utf-8 | |
54 | HGENCODING=utf-8 hg log |
|
54 | HGENCODING=utf-8 hg log | |
|
55 | ||||
|
56 | HGENCODING=dolphin hg log No newline at end of file |
@@ -10,7 +10,6 b' M a' | |||||
10 | ? latin-1-tag |
|
10 | ? latin-1-tag | |
11 | ? utf-8 |
|
11 | ? utf-8 | |
12 | abort: decoding near ' encoded: �': 'ascii' codec can't decode byte 0xe9 in position 20: ordinal not in range(128)! |
|
12 | abort: decoding near ' encoded: �': 'ascii' codec can't decode byte 0xe9 in position 20: ordinal not in range(128)! | |
13 |
|
||||
14 | transaction abort! |
|
13 | transaction abort! | |
15 | rollback completed |
|
14 | rollback completed | |
16 | % these should work |
|
15 | % these should work | |
@@ -165,3 +164,4 b' user: test' | |||||
165 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
164 | date: Mon Jan 12 13:46:40 1970 +0000 | |
166 | summary: latin-1 e': И = u'\xe9' |
|
165 | summary: latin-1 e': И = u'\xe9' | |
167 |
|
166 | |||
|
167 | abort: unknown encoding: dolphin, please check your locale settings |
General Comments 0
You need to be logged in to leave comments.
Login now