[PATCH 1 of 2] debuginstall: use codecs.lookup() to detect invalid encoding
Yuya Nishihara
yuya at tcha.org
Thu Sep 7 13:54:28 UTC 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1504790843 -32400
# Thu Sep 07 22:27:23 2017 +0900
# Node ID 5fda73a5468d3789bccdcb2da6d6b56e5ca2410b
# Parent 1104718fb0907a4a841e6a24006c0c7fcb9caa9e
debuginstall: use codecs.lookup() to detect invalid encoding
encoding.fromlocal() never tries to decode an ascii string since 853574db5b12,
and there's no universal non-ascii string which can be decoded as any valid
character set.
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -7,6 +7,7 @@
from __future__ import absolute_import
+import codecs
import collections
import difflib
import errno
@@ -997,8 +998,8 @@ def debuginstall(ui, **opts):
fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding)
err = None
try:
- encoding.fromlocal("test")
- except error.Abort as inst:
+ codecs.lookup(pycompat.sysstr(encoding.encoding))
+ except LookupError as inst:
err = inst
problems += 1
fm.condwrite(err, 'encodingerror', _(" %s\n"
diff --git a/tests/test-install.t b/tests/test-install.t
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -76,6 +76,11 @@ hg debuginstall with no username
1 problems detected, please check your install!
[1]
+hg debuginstall with invalid encoding
+ $ HGENCODING=invalidenc hg debuginstall | grep encoding
+ checking encoding (invalidenc)...
+ unknown encoding: invalidenc
+
path variables are expanded (~ is the same as $TESTTMP)
$ mkdir tools
$ touch tools/testeditor.exe
More information about the Mercurial-devel
mailing list