diff mercurial/url.py @ 43506:9f70512ae2cf

cleanup: remove pointless r-prefixes on single-quoted strings This is the promised second step on single-quoted strings. These had existed because our source transformer didn't turn r'' into b'', so we had tagged some strings as r-strings to get "native" strings on both Pythons. Now that the transformer is gone, we can dispense with this nonsense. Methodology: I ran hg locate 'set:added() or modified() or clean()' | egrep '.*\.py$' | xargs egrep --color=never -n -- \[\^b\]\[\^a-z\]r\'\[\^\'\\\\\]\*\'\[\^\'\ in an emacs grep-mode buffer, and then used a keyboard macro to iterate over the results and remove the r prefix as needed. # skip-blame removing unneeded r prefixes left over from Python 3 migration. Differential Revision: https://phab.mercurial-scm.org/D7306
author Augie Fackler <augie@google.com>
date Fri, 08 Nov 2019 11:19:20 -0800
parents d783f945a701
children 9d2b2df2c2ba
line wrap: on
line diff
--- a/mercurial/url.py	Sun Nov 10 07:30:14 2019 -0800
+++ b/mercurial/url.py	Fri Nov 08 11:19:20 2019 -0800
@@ -147,7 +147,7 @@
             # Keys and values need to be str because the standard library
             # expects them to be.
             proxyurl = str(proxy)
-            proxies = {r'http': proxyurl, r'https': proxyurl}
+            proxies = {'http': proxyurl, 'https': proxyurl}
             ui.debug(b'proxying through %s\n' % util.hidepassword(bytes(proxy)))
         else:
             proxies = {}
@@ -204,8 +204,8 @@
 def _generic_start_transaction(handler, h, req):
     tunnel_host = req._tunnel_host
     if tunnel_host:
-        if tunnel_host[:7] not in [r'http://', r'https:/']:
-            tunnel_host = r'https://' + tunnel_host
+        if tunnel_host[:7] not in ['http://', 'https:/']:
+            tunnel_host = 'https://' + tunnel_host
         new_tunnel = True
     else:
         tunnel_host = urllibcompat.getselector(req)
@@ -228,7 +228,7 @@
         [
             (x, self.headers[x])
             for x in self.headers
-            if x.lower().startswith(r'proxy-')
+            if x.lower().startswith('proxy-')
         ]
     )
     self.send(b'CONNECT %s HTTP/1.0\r\n' % self.realhostport)
@@ -522,7 +522,7 @@
         )
         if pw is not None:
             raw = b"%s:%s" % (pycompat.bytesurl(user), pycompat.bytesurl(pw))
-            auth = r'Basic %s' % pycompat.strurl(base64.b64encode(raw).strip())
+            auth = 'Basic %s' % pycompat.strurl(base64.b64encode(raw).strip())
             if req.get_header(self.auth_header, None) == auth:
                 return None
             self.auth = auth
@@ -655,16 +655,16 @@
     # do look at this value.
     if not useragent:
         agent = b'mercurial/proto-1.0 (Mercurial %s)' % util.version()
-        opener.addheaders = [(r'User-agent', pycompat.sysstr(agent))]
+        opener.addheaders = [('User-agent', pycompat.sysstr(agent))]
     else:
-        opener.addheaders = [(r'User-agent', pycompat.sysstr(useragent))]
+        opener.addheaders = [('User-agent', pycompat.sysstr(useragent))]
 
     # This header should only be needed by wire protocol requests. But it has
     # been sent on all requests since forever. We keep sending it for backwards
     # compatibility reasons. Modern versions of the wire protocol use
     # X-HgProto-<N> for advertising client support.
     if sendaccept:
-        opener.addheaders.append((r'Accept', r'application/mercurial-0.1'))
+        opener.addheaders.append(('Accept', 'application/mercurial-0.1'))
 
     return opener