[PATCH 1 of 4 py3 v2] encoding: make encoding.encoding be a native str and add encodingb
Augie Fackler
raf at durin42.com
Sun Mar 12 21:51:15 UTC 2017
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1489303712 14400
# Sun Mar 12 03:28:32 2017 -0400
# Node ID 4455c6cdbf1e9cd524b43c69ecefef819e0b4e30
# Parent 7dd2f51f38ac224cec522d093ff6f805beb0dd3e
encoding: make encoding.encoding be a native str and add encodingb
It turns out we need the encoding name both ways. Ugh.
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -965,7 +965,7 @@ def debuginstall(ui, **opts):
fm.startitem()
# encoding
- fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding)
+ fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encodingb())
err = None
try:
encoding.fromlocal("test")
diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -100,6 +100,15 @@ except locale.Error:
encodingmode = environ.get("HGENCODINGMODE", "strict")
fallbackencoding = 'ISO-8859-1'
+if pycompat.ispy3:
+ def encodingb():
+ return encoding.encode('ascii')
+ # TODO: are all encodings sure to be ascii names?
+ encoding = encoding.decode('ascii')
+else:
+ def encodingb():
+ return encoding
+
class localstr(str):
'''This class allows strings that are unmodified to be
round-tripped to the local encoding and back'''
diff --git a/tests/test-check-code.t b/tests/test-check-code.t
--- a/tests/test-check-code.t
+++ b/tests/test-check-code.t
@@ -22,7 +22,7 @@ New errors are not allowed. Warnings are
mercurial/encoding.py:61:
> for k, v in os.environ.items())
use encoding.environ instead (py3)
- mercurial/encoding.py:203:
+ mercurial/encoding.py:212:
> for k, v in os.environ.items())
use encoding.environ instead (py3)
Skipping mercurial/httpclient/__init__.py it has no-che?k-code (glob)
More information about the Mercurial-devel
mailing list