Submitter | Augie Fackler |
---|---|
Date | March 12, 2017, 7:49 p.m. |
Message ID | <19f6f41baa5ef326d3cc.1489348197@augie-macbookair2.roam.corp.google.com> |
Download | mbox | patch |
Permalink | /patch/19229/ |
State | Accepted |
Headers | show |
Comments
On Sun, 12 Mar 2017 15:49:57 -0400, Augie Fackler wrote: > # HG changeset patch > # User Augie Fackler <augie@google.com> > # Date 1489303712 14400 > # Sun Mar 12 03:28:32 2017 -0400 > # Node ID 19f6f41baa5ef326d3cc953093c5d7ff5dcc4427 > # Parent 84996257b560fa41535e4d0360cb33436662581c > 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,11 @@ except locale.Error: > encodingmode = environ.get("HGENCODINGMODE", "strict") > fallbackencoding = 'ISO-8859-1' > > +encodingb = encoding > +if pycompat.ispy3: > + # TODO: are all encodings sure to be ascii names? > + encoding = encoding.decode('ascii') Unfortunately encoding.encoding isn't readonly. dispatch, hgweb and convert overwrite it. Maybe we can add unicode variants of encoding.from/tolocal() instead?
Patch
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,11 @@ except locale.Error: encodingmode = environ.get("HGENCODINGMODE", "strict") fallbackencoding = 'ISO-8859-1' +encodingb = encoding +if pycompat.ispy3: + # TODO: are all encodings sure to be ascii names? + encoding = encoding.decode('ascii') + 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:208: > for k, v in os.environ.items()) use encoding.environ instead (py3) Skipping mercurial/httpclient/__init__.py it has no-che?k-code (glob)