From patchwork Sat Feb 17 10:07:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 5] py3: fix bytes-unicode dance while building docstring of extdiff From: Yuya Nishihara X-Patchwork-Id: 28022 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sat, 17 Feb 2018 19:07:37 +0900 # HG changeset patch # User Yuya Nishihara # Date 1518858891 -32400 # Sat Feb 17 18:14:51 2018 +0900 # Node ID c9ac00127748f7ba34ed4119d2802fba4945235a # Parent d5e06baf9e6bc6705fb4c7e7ab1926bca0a2bae3 py3: fix bytes-unicode dance while building docstring of extdiff diff --git a/hgext/extdiff.py b/hgext/extdiff.py --- a/hgext/extdiff.py +++ b/hgext/extdiff.py @@ -366,7 +366,7 @@ class savedcmd(object): # We can't pass non-ASCII through docstrings (and path is # in an unknown encoding anyway) docpath = util.escapestr(path) - self.__doc__ = self.__doc__ % {'path': util.uirepr(docpath)} + self.__doc__ %= {r'path': pycompat.sysstr(util.uirepr(docpath))} self._cmdline = cmdline def __call__(self, ui, repo, *pats, **opts): diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -2427,7 +2427,7 @@ def forcebytestr(obj): def uirepr(s): # Avoid double backslash in Windows path repr() - return repr(s).replace('\\\\', '\\') + return pycompat.byterepr(pycompat.bytestr(s)).replace(b'\\\\', b'\\') # delay import of textwrap def MBTextWrapper(**kwargs):