py3: switch blackbox to use pycompat.encodeutf8

Summary:
ui.log apparently receives non-utf8 data occasionally, which makes the
encoding fail. Let's change this to not encode on python2 (by using pycompat).
As we migrate to python 3 all the strings should become unicode, and this will once
again enforce utf8 encoding

Reviewed By: xavierd

Differential Revision: D19819700

fbshipit-source-id: 66da26d00d1b1c4286e325f0574ad7ff478e5d1f
This commit is contained in:
Durham Goode 2020-02-11 09:36:57 -08:00 committed by Facebook Github Bot
parent dff471bcbb
commit 0ccfdfdb6e

View File

@ -49,7 +49,7 @@ import weakref
from edenscm.mercurial import extensions, registrar, ui as uimod, util
from edenscm.mercurial.i18n import _
from edenscm.mercurial.node import hex
from edenscm.mercurial.pycompat import range
from edenscm.mercurial.pycompat import encodeutf8, range
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@ -206,7 +206,7 @@ def wrapui(ui):
line = fmt % args
if not line.endswith("\n"):
line += "\n"
fp.write(line.encode("utf-8"))
fp.write(encodeutf8(line))
except (IOError, OSError) as err:
self.debug("warning: cannot write to blackbox.log: %s\n" % err.strerror)
# do not restore _bbinlog intentionally to avoid failed