py3: use r'' instead of sysstr('') to get around code transformer
authorYuya Nishihara <yuya@tcha.org>
Sat, 10 Mar 2018 15:57:16 +0900
changeset 36835 5bc7ff103081
parent 36834 1527f40de3b3
child 36836 a00c38b33047
py3: use r'' instead of sysstr('') to get around code transformer Fewer function calls should be better.
hgext/convert/subversion.py
hgext/gpg.py
hgext/transplant.py
mercurial/bundlerepo.py
mercurial/changegroup.py
mercurial/chgserver.py
mercurial/commandserver.py
mercurial/debugcommands.py
mercurial/filemerge.py
mercurial/httppeer.py
mercurial/i18n.py
mercurial/patch.py
mercurial/urllibcompat.py
mercurial/util.py
mercurial/wireproto.py
mercurial/worker.py
--- a/hgext/convert/subversion.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/hgext/convert/subversion.py	Sat Mar 10 15:57:16 2018 +0900
@@ -1310,7 +1310,7 @@
             self.setexec = []
 
         fd, messagefile = tempfile.mkstemp(prefix='hg-convert-')
-        fp = os.fdopen(fd, pycompat.sysstr('wb'))
+        fp = os.fdopen(fd, r'wb')
         fp.write(util.tonativeeol(commit.desc))
         fp.close()
         try:
--- a/hgext/gpg.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/hgext/gpg.py	Sat Mar 10 15:57:16 2018 +0900
@@ -60,11 +60,11 @@
         try:
             # create temporary files
             fd, sigfile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".sig")
-            fp = os.fdopen(fd, pycompat.sysstr('wb'))
+            fp = os.fdopen(fd, r'wb')
             fp.write(sig)
             fp.close()
             fd, datafile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".txt")
-            fp = os.fdopen(fd, pycompat.sysstr('wb'))
+            fp = os.fdopen(fd, r'wb')
             fp.write(data)
             fp.close()
             gpgcmd = ("%s --logger-fd 1 --status-fd 1 --verify "
--- a/hgext/transplant.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/hgext/transplant.py	Sat Mar 10 15:57:16 2018 +0900
@@ -212,7 +212,7 @@
                     patchfile = None
                 else:
                     fd, patchfile = tempfile.mkstemp(prefix='hg-transplant-')
-                    fp = os.fdopen(fd, pycompat.sysstr('wb'))
+                    fp = os.fdopen(fd, r'wb')
                     gen = patch.diff(source, parent, node, opts=diffopts)
                     for chunk in gen:
                         fp.write(chunk)
@@ -260,7 +260,7 @@
         self.ui.status(_('filtering %s\n') % patchfile)
         user, date, msg = (changelog[1], changelog[2], changelog[4])
         fd, headerfile = tempfile.mkstemp(prefix='hg-transplant-')
-        fp = os.fdopen(fd, pycompat.sysstr('wb'))
+        fp = os.fdopen(fd, r'wb')
         fp.write("# HG changeset patch\n")
         fp.write("# User %s\n" % user)
         fp.write("# Date %d %d\n" % date)
--- a/mercurial/bundlerepo.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/bundlerepo.py	Sat Mar 10 15:57:16 2018 +0900
@@ -349,7 +349,7 @@
                                         suffix=suffix)
         self.tempfile = temp
 
-        with os.fdopen(fdtemp, pycompat.sysstr('wb')) as fptemp:
+        with os.fdopen(fdtemp, r'wb') as fptemp:
             fptemp.write(header)
             while True:
                 chunk = readfn(2**18)
--- a/mercurial/changegroup.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/changegroup.py	Sat Mar 10 15:57:16 2018 +0900
@@ -75,7 +75,7 @@
                 fh = open(filename, "wb", 131072)
         else:
             fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg")
-            fh = os.fdopen(fd, pycompat.sysstr("wb"))
+            fh = os.fdopen(fd, r"wb")
         cleanup = filename
         for c in chunks:
             fh.write(c)
--- a/mercurial/chgserver.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/chgserver.py	Sat Mar 10 15:57:16 2018 +0900
@@ -296,9 +296,9 @@
 
 _iochannels = [
     # server.ch, ui.fp, mode
-    ('cin', 'fin', pycompat.sysstr('rb')),
-    ('cout', 'fout', pycompat.sysstr('wb')),
-    ('cerr', 'ferr', pycompat.sysstr('wb')),
+    ('cin', 'fin', r'rb'),
+    ('cout', 'fout', r'wb'),
+    ('cerr', 'ferr', r'wb'),
 ]
 
 class chgcmdserver(commandserver.server):
--- a/mercurial/commandserver.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/commandserver.py	Sat Mar 10 15:57:16 2018 +0900
@@ -303,8 +303,8 @@
     ui.flush()
     newfiles = []
     nullfd = os.open(os.devnull, os.O_RDWR)
-    for f, sysf, mode in [(ui.fin, util.stdin, pycompat.sysstr('rb')),
-                          (ui.fout, util.stdout, pycompat.sysstr('wb'))]:
+    for f, sysf, mode in [(ui.fin, util.stdin, r'rb'),
+                          (ui.fout, util.stdout, r'wb')]:
         if f is sysf:
             newfd = os.dup(f.fileno())
             os.dup2(nullfd, f.fileno())
--- a/mercurial/debugcommands.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/debugcommands.py	Sat Mar 10 15:57:16 2018 +0900
@@ -1119,7 +1119,7 @@
 
     def writetemp(contents):
         (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
-        f = os.fdopen(fd, pycompat.sysstr("wb"))
+        f = os.fdopen(fd, r"wb")
         f.write(contents)
         f.close()
         return name
--- a/mercurial/filemerge.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/filemerge.py	Sat Mar 10 15:57:16 2018 +0900
@@ -674,7 +674,7 @@
         pre = "%s~%s." % (os.path.basename(fullbase), prefix)
         (fd, name) = tempfile.mkstemp(prefix=pre, suffix=ext)
         data = repo.wwritedata(ctx.path(), ctx.data())
-        f = os.fdopen(fd, pycompat.sysstr("wb"))
+        f = os.fdopen(fd, r"wb")
         f.write(data)
         f.close()
         return name
--- a/mercurial/httppeer.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/httppeer.py	Sat Mar 10 15:57:16 2018 +0900
@@ -459,7 +459,7 @@
         try:
             # dump bundle to disk
             fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg")
-            fh = os.fdopen(fd, pycompat.sysstr("wb"))
+            fh = os.fdopen(fd, r"wb")
             d = fp.read(4096)
             while d:
                 fh.write(d)
--- a/mercurial/i18n.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/i18n.py	Sat Mar 10 15:57:16 2018 +0900
@@ -50,7 +50,7 @@
 
 def setdatapath(datapath):
     datapath = pycompat.fsdecode(datapath)
-    localedir = os.path.join(datapath, pycompat.sysstr('locale'))
+    localedir = os.path.join(datapath, r'locale')
     t = gettextmod.translation(r'hg', localedir, _languages, fallback=True)
     global _ugettext
     try:
--- a/mercurial/patch.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/patch.py	Sat Mar 10 15:57:16 2018 +0900
@@ -216,7 +216,7 @@
 
     data = {}
     fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
-    tmpfp = os.fdopen(fd, pycompat.sysstr('wb'))
+    tmpfp = os.fdopen(fd, r'wb')
     try:
         msg = pycompat.emailparser().parse(fileobj)
 
@@ -1106,7 +1106,7 @@
                 ncpatchfp = None
                 try:
                     # Write the initial patch
-                    f = os.fdopen(patchfd, pycompat.sysstr("w"))
+                    f = os.fdopen(patchfd, r"w")
                     chunk.header.write(f)
                     chunk.write(f)
                     f.write('\n'.join(['# ' + i for i in phelp.splitlines()]))
--- a/mercurial/urllibcompat.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/urllibcompat.py	Sat Mar 10 15:57:16 2018 +0900
@@ -18,7 +18,7 @@
         """Add items that will be populated at the first access"""
         items = map(_sysstr, items)
         self._aliases.update(
-            (item.replace(_sysstr('_'), _sysstr('')).lower(), (origin, item))
+            (item.replace(r'_', r'').lower(), (origin, item))
             for item in items)
 
     def _registeralias(self, origin, attr, name):
--- a/mercurial/util.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/util.py	Sat Mar 10 15:57:16 2018 +0900
@@ -91,7 +91,7 @@
 # destined stdout with a pipe destined stdout (e.g. pager), we want line
 # buffering
 if isatty(stdout):
-    stdout = os.fdopen(stdout.fileno(), pycompat.sysstr('wb'), 1)
+    stdout = os.fdopen(stdout.fileno(), r'wb', 1)
 
 if pycompat.iswindows:
     from . import windows as platform
@@ -1251,7 +1251,7 @@
     inname, outname = None, None
     try:
         infd, inname = tempfile.mkstemp(prefix='hg-filter-in-')
-        fp = os.fdopen(infd, pycompat.sysstr('wb'))
+        fp = os.fdopen(infd, r'wb')
         fp.write(s)
         fp.close()
         outfd, outname = tempfile.mkstemp(prefix='hg-filter-out-')
@@ -1413,7 +1413,7 @@
     """
     if _hgexecutable is None:
         hg = encoding.environ.get('HG')
-        mainmod = sys.modules[pycompat.sysstr('__main__')]
+        mainmod = sys.modules[r'__main__']
         if hg:
             _sethgexecutable(hg)
         elif mainfrozen():
--- a/mercurial/wireproto.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/wireproto.py	Sat Mar 10 15:57:16 2018 +0900
@@ -1027,7 +1027,7 @@
 
             # write bundle data to temporary file because it can be big
             fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-')
-            fp = os.fdopen(fd, pycompat.sysstr('wb+'))
+            fp = os.fdopen(fd, r'wb+')
             r = 0
             try:
                 proto.forwardpayload(fp)
--- a/mercurial/worker.py	Sat Mar 10 15:50:09 2018 +0900
+++ b/mercurial/worker.py	Sat Mar 10 15:57:16 2018 +0900
@@ -176,7 +176,7 @@
                     os._exit(ret & 255)
         pids.add(pid)
     os.close(wfd)
-    fp = os.fdopen(rfd, pycompat.sysstr('rb'), 0)
+    fp = os.fdopen(rfd, r'rb', 0)
     def cleanup():
         signal.signal(signal.SIGINT, oldhandler)
         waitforworkers()