Patchwork [2,of,5] py3: fix bytes-unicode dance while building docstring of extdiff

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 17, 2018, 10:07 a.m.
Message ID <c9ac00127748f7ba34ed.1518862057@mimosa>
Download mbox | patch
Permalink /patch/28022/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 17, 2018, 10:07 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# 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

Patch

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):