##// END OF EJS Templates
Allow the user to specify the fallback encoding for the changelog...
Alexis S. L. Carvalho -
r3835:d1ce5461 default
parent child Browse files
Show More
@@ -388,6 +388,9 b' ui::'
388 Print debugging information. True or False. Default is False.
388 Print debugging information. True or False. Default is False.
389 editor;;
389 editor;;
390 The editor to use during a commit. Default is $EDITOR or "vi".
390 The editor to use during a commit. Default is $EDITOR or "vi".
391 fallbackencoding;;
392 Encoding to try if it's not possible to decode the changelog using
393 UTF-8. Default is ISO-8859-1.
391 ignore;;
394 ignore;;
392 A file to read per-user ignore patterns from. This file should be in
395 A file to read per-user ignore patterns from. This file should be in
393 the same format as a repository-wide .hgignore file. This option
396 the same format as a repository-wide .hgignore file. This option
@@ -72,6 +72,10 b' class localrepository(repo.repository):'
72 self.manifest = manifest.manifest(self.sopener, v)
72 self.manifest = manifest.manifest(self.sopener, v)
73 self.changelog = changelog.changelog(self.sopener, v)
73 self.changelog = changelog.changelog(self.sopener, v)
74
74
75 fallback = self.ui.config('ui', 'fallbackencoding')
76 if fallback:
77 util._fallbackencoding = fallback
78
75 # the changelog might not have the inline index flag
79 # the changelog might not have the inline index flag
76 # on. If the format of the changelog is the same as found in
80 # on. If the format of the changelog is the same as found in
77 # .hgrc, apply any flags found in the .hgrc as well.
81 # .hgrc, apply any flags found in the .hgrc as well.
@@ -19,6 +19,7 b' demandload(globals(), "os threading time'
19
19
20 _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding()
20 _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding()
21 _encodingmode = os.environ.get("HGENCODINGMODE", "strict")
21 _encodingmode = os.environ.get("HGENCODINGMODE", "strict")
22 _fallbackencoding = 'ISO-8859-1'
22
23
23 def tolocal(s):
24 def tolocal(s):
24 """
25 """
@@ -30,7 +31,7 b' def tolocal(s):'
30 using UTF-8, then Latin-1, and failing that, we use UTF-8 and
31 using UTF-8, then Latin-1, and failing that, we use UTF-8 and
31 replace unknown characters.
32 replace unknown characters.
32 """
33 """
33 for e in "utf-8 latin1".split():
34 for e in ('UTF-8', _fallbackencoding):
34 try:
35 try:
35 u = s.decode(e) # attempt strict decoding
36 u = s.decode(e) # attempt strict decoding
36 return u.encode(_encoding, "replace")
37 return u.encode(_encoding, "replace")
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -47,3 +47,8 b' echo % latin-1'
47 HGENCODING=latin-1 hg branches
47 HGENCODING=latin-1 hg branches
48 echo % utf-8
48 echo % utf-8
49 HGENCODING=utf-8 hg branches
49 HGENCODING=utf-8 hg branches
50
51 echo '[ui]' >> .hg/hgrc
52 echo 'fallbackencoding = euc-jp' >> .hg/hgrc
53 echo % utf-8
54 HGENCODING=utf-8 hg log
@@ -1,7 +1,7 b''
1 adding changesets
1 adding changesets
2 adding manifests
2 adding manifests
3 adding file changes
3 adding file changes
4 added 1 changesets with 1 changes to 1 files
4 added 2 changesets with 2 changes to 1 files
5 (run 'hg update' to get a working copy)
5 (run 'hg update' to get a working copy)
6 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
6 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
7 % should fail with encoding error
7 % should fail with encoding error
@@ -15,104 +15,153 b' transaction abort!'
15 rollback completed
15 rollback completed
16 % these should work
16 % these should work
17 % ascii
17 % ascii
18 changeset: 4:d8a5d9eaf41e
18 changeset: 5:e4ed49b8a8f0
19 branch: ?
19 branch: ?
20 tag: tip
20 tag: tip
21 user: test
21 user: test
22 date: Thu Jan 01 00:00:00 1970 +0000
22 date: Thu Jan 01 00:00:00 1970 +0000
23 summary: latin1 branch
23 summary: latin1 branch
24
24
25 changeset: 3:5edfc7acb541
25 changeset: 4:a02ca5a58e99
26 user: test
26 user: test
27 date: Thu Jan 01 00:00:00 1970 +0000
27 date: Thu Jan 01 00:00:00 1970 +0000
28 summary: Added tag ? for changeset 91878608adb3
28 summary: Added tag ? for changeset d47908dab82f
29
29
30 changeset: 2:91878608adb3
30 changeset: 3:d47908dab82f
31 tag: ?
31 tag: ?
32 user: test
32 user: test
33 date: Thu Jan 01 00:00:00 1970 +0000
33 date: Thu Jan 01 00:00:00 1970 +0000
34 summary: utf-8 e' encoded: ?
34 summary: utf-8 e' encoded: ?
35
35
36 changeset: 1:6355cacf842e
36 changeset: 2:9db1985f3097
37 user: test
37 user: test
38 date: Thu Jan 01 00:00:00 1970 +0000
38 date: Thu Jan 01 00:00:00 1970 +0000
39 summary: latin-1 e' encoded: ?
39 summary: latin-1 e' encoded: ?
40
40
41 changeset: 1:af6e0db4427c
42 user: test
43 date: Thu Jan 01 00:00:00 1970 +0000
44 summary: euc-jp: ?????? = u'\u65e5\u672c\u8a9e'
45
41 changeset: 0:60aad1dd20a9
46 changeset: 0:60aad1dd20a9
42 user: test
47 user: test
43 date: Thu Jan 01 00:00:00 1970 +0000
48 date: Thu Jan 01 00:00:00 1970 +0000
44 summary: latin-1 e': ?
49 summary: latin-1 e': ?
45
50
46 % latin-1
51 % latin-1
47 changeset: 4:d8a5d9eaf41e
52 changeset: 5:e4ed49b8a8f0
48 branch: �
53 branch: �
49 tag: tip
54 tag: tip
50 user: test
55 user: test
51 date: Thu Jan 01 00:00:00 1970 +0000
56 date: Thu Jan 01 00:00:00 1970 +0000
52 summary: latin1 branch
57 summary: latin1 branch
53
58
54 changeset: 3:5edfc7acb541
59 changeset: 4:a02ca5a58e99
55 user: test
60 user: test
56 date: Thu Jan 01 00:00:00 1970 +0000
61 date: Thu Jan 01 00:00:00 1970 +0000
57 summary: Added tag � for changeset 91878608adb3
62 summary: Added tag � for changeset d47908dab82f
58
63
59 changeset: 2:91878608adb3
64 changeset: 3:d47908dab82f
60 tag: �
65 tag: �
61 user: test
66 user: test
62 date: Thu Jan 01 00:00:00 1970 +0000
67 date: Thu Jan 01 00:00:00 1970 +0000
63 summary: utf-8 e' encoded: �
68 summary: utf-8 e' encoded: �
64
69
65 changeset: 1:6355cacf842e
70 changeset: 2:9db1985f3097
66 user: test
71 user: test
67 date: Thu Jan 01 00:00:00 1970 +0000
72 date: Thu Jan 01 00:00:00 1970 +0000
68 summary: latin-1 e' encoded: �
73 summary: latin-1 e' encoded: �
69
74
75 changeset: 1:af6e0db4427c
76 user: test
77 date: Thu Jan 01 00:00:00 1970 +0000
78 summary: euc-jp: ���ܸ� = u'\u65e5\u672c\u8a9e'
79
70 changeset: 0:60aad1dd20a9
80 changeset: 0:60aad1dd20a9
71 user: test
81 user: test
72 date: Thu Jan 01 00:00:00 1970 +0000
82 date: Thu Jan 01 00:00:00 1970 +0000
73 summary: latin-1 e': �
83 summary: latin-1 e': �
74
84
75 % utf-8
85 % utf-8
76 changeset: 4:d8a5d9eaf41e
86 changeset: 5:e4ed49b8a8f0
77 branch: é
87 branch: é
78 tag: tip
88 tag: tip
79 user: test
89 user: test
80 date: Thu Jan 01 00:00:00 1970 +0000
90 date: Thu Jan 01 00:00:00 1970 +0000
81 summary: latin1 branch
91 summary: latin1 branch
82
92
83 changeset: 3:5edfc7acb541
93 changeset: 4:a02ca5a58e99
84 user: test
94 user: test
85 date: Thu Jan 01 00:00:00 1970 +0000
95 date: Thu Jan 01 00:00:00 1970 +0000
86 summary: Added tag é for changeset 91878608adb3
96 summary: Added tag é for changeset d47908dab82f
87
97
88 changeset: 2:91878608adb3
98 changeset: 3:d47908dab82f
89 tag: é
99 tag: é
90 user: test
100 user: test
91 date: Thu Jan 01 00:00:00 1970 +0000
101 date: Thu Jan 01 00:00:00 1970 +0000
92 summary: utf-8 e' encoded: é
102 summary: utf-8 e' encoded: é
93
103
94 changeset: 1:6355cacf842e
104 changeset: 2:9db1985f3097
95 user: test
105 user: test
96 date: Thu Jan 01 00:00:00 1970 +0000
106 date: Thu Jan 01 00:00:00 1970 +0000
97 summary: latin-1 e' encoded: é
107 summary: latin-1 e' encoded: é
98
108
109 changeset: 1:af6e0db4427c
110 user: test
111 date: Thu Jan 01 00:00:00 1970 +0000
112 summary: euc-jp: ÆüËܸì = u'\u65e5\u672c\u8a9e'
113
99 changeset: 0:60aad1dd20a9
114 changeset: 0:60aad1dd20a9
100 user: test
115 user: test
101 date: Thu Jan 01 00:00:00 1970 +0000
116 date: Thu Jan 01 00:00:00 1970 +0000
102 summary: latin-1 e': é
117 summary: latin-1 e': é
103
118
104 % ascii
119 % ascii
105 tip 4:d8a5d9eaf41e
120 tip 5:e4ed49b8a8f0
106 ? 2:91878608adb3
121 ? 3:d47908dab82f
107 % latin-1
122 % latin-1
108 tip 4:d8a5d9eaf41e
123 tip 5:e4ed49b8a8f0
109 2:91878608adb3
124 3:d47908dab82f
125 % utf-8
126 tip 5:e4ed49b8a8f0
127 é 3:d47908dab82f
128 % ascii
129 ? 5:e4ed49b8a8f0
130 % latin-1
131 � 5:e4ed49b8a8f0
132 % utf-8
133 é 5:e4ed49b8a8f0
110 % utf-8
134 % utf-8
111 tip 4:d8a5d9eaf41e
135 changeset: 5:e4ed49b8a8f0
112 é 2:91878608adb3
136 branch: é
113 % ascii
137 tag: tip
114 ? 4:d8a5d9eaf41e
138 user: test
115 % latin-1
139 date: Thu Jan 01 00:00:00 1970 +0000
116 � 4:d8a5d9eaf41e
140 summary: latin1 branch
117 % utf-8
141
118 é 4:d8a5d9eaf41e
142 changeset: 4:a02ca5a58e99
143 user: test
144 date: Thu Jan 01 00:00:00 1970 +0000
145 summary: Added tag é for changeset d47908dab82f
146
147 changeset: 3:d47908dab82f
148 tag: é
149 user: test
150 date: Thu Jan 01 00:00:00 1970 +0000
151 summary: utf-8 e' encoded: é
152
153 changeset: 2:9db1985f3097
154 user: test
155 date: Thu Jan 01 00:00:00 1970 +0000
156 summary: latin-1 e' encoded: é
157
158 changeset: 1:af6e0db4427c
159 user: test
160 date: Thu Jan 01 00:00:00 1970 +0000
161 summary: euc-jp: 日本語 = u'\u65e5\u672c\u8a9e'
162
163 changeset: 0:60aad1dd20a9
164 user: test
165 date: Thu Jan 01 00:00:00 1970 +0000
166 summary: latin-1 e': �
167
General Comments 0
You need to be logged in to leave comments. Login now